Web Scraper Lite

Home › Guides

How to import a table from a website into Google Sheets

Google Sheets has a built-in formula, IMPORTHTML, that pulls a table straight from a public webpage and keeps it updated. It is excellent when it works. This guide shows how to use it, how to fix the common errors, and what to do for pages it can't read.

Updated · by yxonchan

The IMPORTHTML formula

According to Google's documentation the syntax is:

=IMPORTHTML(url, query, index)

Step by step

  1. Copy the page URL. Use the full address including https://.
  2. Type the formula in an empty cell. For example =IMPORTHTML("https://en.wikipedia.org/wiki/Demographics_of_India", "table", 4). The table appears and spills into the cells below and to the right.
  3. Find the right index. If you got the wrong table, change the last number (1, 2, 3...) until you see the one you want.
  4. Keep only the columns you need. Wrap the formula in QUERY or INDEX, as shown below.

Google's own sample formula is =IMPORTHTML("http://en.wikipedia.org/wiki/Demographics_of_India","table",4). You can also keep the inputs in cells and write =IMPORTHTML(A2, B2, C2), which makes it easy to try different indexes.

Semicolons or commas? In locales that use a comma as the decimal separator (for example Germany or Brazil), Google Sheets separates formula arguments with semicolons: =IMPORTHTML("https://…"; "table"; 1). Your spreadsheet locale is under File > Settings.

Finding the right index

The index counts every <table> in the page source, including ones used for layout or hidden on screen, so "the second table I can see" is not always index 2. Put the index in a cell, reference it in the formula, and step through 1, 2, 3 until the preview matches. On Wikipedia the infobox at the top is usually a table too.

Picking columns and rows

IMPORTHTML returns the whole table. To keep only part of it:

How often it refreshes

Google says IMPORTHTML, IMPORTDATA and IMPORTXML check for updates about every hour while the spreadsheet is open. Reloading the browser tab does not force a refresh, but deleting and re-entering the formula does. If you need a fixed snapshot instead of a live import, select the range, copy it and use Edit > Paste special > Values only.

What IMPORTHTML can't do

IMPORTHTML runs on Google's servers, not in your browser. That explains nearly all of its limits:

The alternative: copy it from your browser

When IMPORTHTML fails, copy the table from the page you already have open. Plain select-and-copy works for simple tables but often merges columns. A table extractor keeps the structure:

  1. Open the page in Chrome (signed in if needed) and click the Web Scraper Lite icon.
  2. Pick the table or list under Data sources. It is outlined on the page so you can check it is the right one.
  3. Click Copy. The data goes to the clipboard as tab-separated values.
  4. In Google Sheets, click cell A1 and press Ctrl+V (Cmd+V on Mac). Every value lands in its own cell.

For large tables, click Export CSV instead and import it with File > Import > Upload. Choose an Import location (for example "Insert new sheet(s)"), leave Separator type on "Detect automatically", and click Import data.

Web Scraper Lite preview with column checkboxes and Copy and Export CSV buttons
Choose columns, then Copy to paste into Google Sheets.

Free, no account, and nothing leaves your browser.

Add Web Scraper Lite to Chrome – free

IMPORTHTML vs copying from the browser

IMPORTHTMLWeb Scraper Lite + paste
Updates automaticallyYes, about hourlyNo, a snapshot
Logged-in pagesNoYes
JavaScript data gridsNoYes
Div-based lists and cardsNo (IMPORTXML sometimes)Yes
Multiple pagesOne formula per page URLUp to 5 pages per run (free)
Works outside ChromeYes, any browserChrome only

Rule of thumb: use IMPORTHTML for public, static tables you want to keep fresh, such as Wikipedia lists or published statistics. Use a browser-side tool for everything else. Exporting to Excel instead? See how to export a website table to Excel.

FAQ

Why does IMPORTHTML return #N/A or "Imported content is empty"?

Usually the index points at the wrong table, the table is built with JavaScript, or the page needs a login. Try other index numbers first; if none work, the data is not in the page's HTML and you will need to copy it from your browser.

Can IMPORTHTML import from a page that requires a login?

No. The formula is executed on Google's servers, which are not signed in to your accounts.

How do I force IMPORTHTML to refresh?

Delete the formula and enter it again, or change one of its inputs. Reloading the browser tab does not trigger a refresh.

Can I paste a web table into Google Sheets without merging columns?

Yes. Copy it as tab-separated values, which is what Web Scraper Lite's Copy button does, and paste into a single cell. Sheets splits the values into columns.

Sources