IMPORTHTML in Google Sheets: Import Tables and Lists

By the Vurge team ·

A printed report with tables and charts next to a laptop.
Photo by Lukas Blazek on Pexels
In this article
  1. How to use IMPORTHTML
  2. Tables vs lists, and why the index confuses people
  3. Keep only the columns and rows you need
  4. IMPORTHTML errors and fixes
  5. Limits you can’t wrap your way around
  6. When IMPORTHTML is the wrong tool
  7. Bottom line

IMPORTHTML imports a table or a list from a web page into Google Sheets. The formula =IMPORTHTML("https://en.wikipedia.org/wiki/List_of_largest_companies_by_revenue", "table", 1) pulls the first HTML table on that page into your sheet, headers included. You choose “table” or “list” and a number for which one. That’s the entire function.

It’s the fastest way to grab a clean table from Wikipedia, a government stats page or a static pricing comparison. It also has hard limits that no amount of formula wrapping will fix, which we’ll get to.

How to use IMPORTHTML

  1. Copy the page URL, with https://, into cell A1.
  2. In A3, type =IMPORTHTML(A1, "table", 1).
  3. Look at what comes back. If it’s the wrong table, change the 1 to 2, then 3.
  4. Once you have the right table, trim it with INDEX or QUERY (examples below).
  5. If you don’t need live updates, copy the range and paste as values.

The syntax:

=IMPORTHTML(url, query, index, [locale])
  • url: the page, in quotes or a cell reference. Include the protocol.
  • query: either "table" or "list". Nothing else is valid.
  • index: which table or list, starting at 1, in the order they appear in the HTML source.
  • locale (optional): language and region for parsing, like "en_US" or "fr_FR". Useful when a European site writes 3,5 and you want the number 3.5.

A computer screen showing a web page layout. Photo by Tranmautritam on Pexels

Tables vs lists, and why the index confuses people

“table” means <table> elements. “list” means <ul> and <ol> elements, which is every bulleted or numbered list on the page.

Google numbers tables and lists separately. So "table", 2 is the second table and "list", 2 is the second list, even if a list sits between those two tables.

Lists catch people out. Site menus, footers and sidebars are usually built with <ul>, so the list you can see in the article might be list 14. Expect some trial and error.

To skip the guessing, open the page in Chrome, press F12 to open DevTools, go to the Console and run:

document.querySelectorAll('table').length

That tells you how many tables the browser sees. One caveat: the browser count includes tables added by JavaScript, which IMPORTHTML can’t see. If the console says 3 and IMPORTHTML only finds 1, the other two were probably built by scripts.

Keep only the columns and rows you need

IMPORTHTML returns the whole table. Wikipedia tables often have eight columns when you want two.

Pick one column with INDEX (0 means “all rows”):

=INDEX(IMPORTHTML(A1, "table", 1), 0, 2)

Pick specific columns and filter rows with QUERY. When data comes from a formula, refer to columns as Col1, Col2 and so on:

=QUERY(IMPORTHTML(A1, "table", 1), "select Col2, Col4 where Col4 is not null", 1)

The final 1 tells QUERY the first row is a header.

Skip the header row entirely:

=QUERY(IMPORTHTML(A1, "table", 1), "select * offset 1", 0)

Grab one cell, say row 5, column 3:

=INDEX(IMPORTHTML(A1, "table", 1), 5, 3)

IMPORTHTML errors and fixes

“Imported content is empty”

Usually one of two things. Your index is higher than the number of tables or lists Google found (try lower numbers). Or the table isn’t a real <table>. Many modern sites build grids out of <div> elements styled to look like tables, and many load table data with JavaScript after the page opens. Check with View Page Source: search for <table. If it’s not there, IMPORTHTML can’t read it.

“Could not fetch url”

Google’s servers couldn’t load the page. Confirm the URL works in an incognito window, includes https://, and isn’t behind a login. Some sites block Google’s fetcher outright. Nothing in the formula fixes that.

Numbers imported as text, or wrong decimals

Add the locale argument matching the site, e.g. =IMPORTHTML(A1, "table", 1, "de_DE"). Footnote markers like [3] on Wikipedia also turn numbers into text. Strip them with REGEXREPLACE in a helper column.

Messy headers and merged cells

Tables with two header rows or merged cells import awkwardly, with headers spilling into data rows. Use QUERY with offset to drop them, then type your own headers.

“Loading data may take a while because of the large number of requests”

You’ve hit Google’s quota for import functions. The limit applies to the sheet’s creator across all their documents, and Google doesn’t publish a number. Cut down the number of IMPORT formulas and paste stable results as values.

Limits you can’t wrap your way around

Imports refresh about once an hour while the file is open, on Google’s schedule. Reopening the file doesn’t trigger a fetch. You also can’t reference volatile functions like NOW() or RAND() inside or upstream of the formula to force it.

It only sees real HTML tables and lists in the raw source. That rules out a large share of modern web apps, dashboards and ecommerce sites.

And it only works by position. If the site adds a table above yours, index 2 becomes index 3 and your sheet silently shows the wrong data. Worth a quick look at results now and then.

When IMPORTHTML is the wrong tool

IMPORTHTML is great when the data is already a table. Wikipedia lists, sports stats, exchange rate tables, public datasets.

It’s no help when the information is spread across many websites, like “the pricing of the cheapest plan” for 80 SaaS companies, or “a one-sentence description” for 200 leads. There’s no table to import. Each site puts that information somewhere different, in a different format.

For that job, an AI scraper that runs in Sheets is the better fit. With Vurge you put the URLs in a column, open the sidebar from Extensions, type the question in plain English, click Scrape, and the answers fill in next to each URL. It reads public pages only, has no free plan (Starter is $20/month for 80 requests, Explorer $50/month for 250; see pricing), and only works inside Google Sheets. Typical uses are lead enrichment and market research. Start with Vurge if that sounds like your sheet.

If you need individual elements rather than whole tables, try IMPORTXML, which uses XPath. For the wider picture, see how to scrape data from a website into Google Sheets.

Bottom line

Use IMPORTHTML whenever the data you want is already a real HTML table or list: try indexes 1 through 5, trim with QUERY, paste as values when done. When you hit “Imported content is empty” on a page that clearly shows a table, it’s almost always JavaScript or divs, and it’s time for a different tool. If your real task is collecting facts across many sites, try Vurge.

Scrape any website into Google Sheets

Write a prompt, click Scrape, get structured data. Plans from $20/month.

Try Vurge

Frequently asked questions

Start with 1 and increase until you see the table you want. Tables and lists are numbered separately in the order they appear in the page's HTML source, so a page's main data table is often not number 1.

Either the index is higher than the number of tables or lists on the page, or the table is built with JavaScript or div elements instead of a real HTML table.

Not by itself, but you can wrap it. =INDEX(IMPORTHTML(A1,"table",1),0,2) returns only the second column, and QUERY lets you select columns and filter rows.

IMPORTHTML only grabs whole tables or lists by position. IMPORTXML uses XPath to grab any element or attribute, which is more flexible but harder to write.

Ready to give your spreadsheet

AI powers?

Pull data from any public website, get it back structured, and make decisions without leaving Google Sheets.

Get Started