IMPORTHTML Function in Google Sheets
Imports a table or list from a web page. The simplest way to scrape structured data from a public webpage without writing code.
Syntax
IMPORTHTML(url, query, index)Returns: A spilled array of the table or list content.
Excel equivalent: Power Query 'From Web' is the rough equivalent in Excel.
Parameters
| Name | Required | Description |
|---|---|---|
| url | Required | The URL of the page to scrape (must be publicly accessible). |
| query | Required | "table" or "list" — what kind of element to import. |
| index | Required | Which table or list on the page (1-based). |
Examples
Import a Wikipedia table
=IMPORTHTML("https://en.wikipedia.org/wiki/List_of_countries_by_GDP_(nominal)", "table", 1)Pulls the first HTML table from the page. Wikipedia is reliably parseable.
Get a list from a page
=IMPORTHTML(A1, "list", 2)URL stored in A1, fetches the 2nd list. Common for navigation menus or ranked lists.
When to use an alternative
- IMPORTXML — You need a specific element by XPath, not a whole table.
- IMPORTDATA — Source is CSV or TSV, not HTML.
- Apps Script + UrlFetchApp — You need authentication, headers, or post-processing.
Common errors and how to fix them
#N/A "Could not fetch URL"
Cause: Page blocks Google's crawler, requires login, or returned an error.
Fix: Test the URL in a private browser window — if it doesn't load there, IMPORTHTML won't work. Some sites block scraping; respect their robots.txt.
Wrong index
Cause: Numbered tables differently than expected.
Fix: Try index 1, 2, 3 until you find the right one. Page may have hidden tables that count.
Slow refresh
Cause: IMPORTHTML caches results aggressively.
Fix: Force a refresh with Ctrl+R or by adding a dummy query parameter to the URL: ?refresh=NOW().
Related functions
Frequently Asked Questions
How often does IMPORTHTML refresh?
Roughly every hour by default, sometimes less often. You can't reliably force more frequent refreshes within the function. For near-real-time data, use Apps Script with a time-driven trigger.
Can IMPORTHTML scrape any site?
Only sites that serve content as plain HTML to Google's crawler. JavaScript-rendered single-page apps won't work — the bot only sees the initial HTML, not what JS would render. Try the page in "View Source" first; if the data isn't in the source, IMPORTHTML can't see it.