Import

Google Sheets IMPORTHTML Function — Syntax, Examples & Tips

Learn how to use IMPORTHTML in Google Sheets to import tables and lists from web pages. Includes syntax, real-world examples, and troubleshooting advice.

Syntax
=IMPORTHTML(url, query, index)

What Is the IMPORTHTML Function?

IMPORTHTML imports an HTML table or list from a public web page directly into your spreadsheet. You point it at a URL, tell it whether you want a table or a list, and specify which one (by index number) if the page contains multiple. It is a quick way to pull structured data from Wikipedia, government sites, sports statistics pages, or any site that presents information in HTML tables without writing any code.

Syntax

=IMPORTHTML(url, query, index)
ParameterDescription
urlThe full URL of the web page containing the table or list.
queryEither "table" or "list". Tells the function what type of HTML element to look for.
indexA number indicating which table or list to import (1 for the first, 2 for the second, etc.).

Basic Examples

Importing a Wikipedia Table

=IMPORTHTML("https://en.wikipedia.org/wiki/List_of_countries_by_population_(United_Nations)", "table", 1)

This pulls the first table from the Wikipedia page listing countries by population. The data arrives with headers and all columns intact, ready for sorting and analysis.

Importing a List

=IMPORTHTML("https://en.wikipedia.org/wiki/Google", "list", 1)

This grabs the first unordered or ordered list from the Google Wikipedia page. Lists are returned as a single column of items.

Trying Different Index Values

If the first table on a page is a navigation bar or sidebar, increment the index:

=IMPORTHTML("https://en.wikipedia.org/wiki/List_of_largest_companies_by_revenue", "table", 2)

Index 2 skips the first table and grabs the second, which is often the main data table on Wikipedia pages. Trial and error is normal here -- start at 1 and increment until you find the right one.

Advanced Examples

Combining IMPORTHTML with QUERY for Filtering

The raw table might contain columns and rows you do not need. QUERY lets you refine the output:

=QUERY(
  IMPORTHTML("https://en.wikipedia.org/wiki/List_of_countries_by_GDP_(nominal)", "table", 1),
  "SELECT Col2, Col3 WHERE Col3 > 1000000 ORDER BY Col3 DESC",
  1
)

This imports the GDP table but only keeps the country name and GDP columns, filtering to economies above 1 trillion and sorting from largest to smallest. The column references (Col1, Col2, etc.) correspond to the table's original column order.

Building a Sports Dashboard

Many sports sites serve stats in HTML tables. For example, importing NBA standings:

=IMPORTHTML("https://www.basketball-reference.com/leagues/NBA_2026_standings.html", "table", 1)

Place this in a dedicated sheet, then use VLOOKUP or QUERY on your dashboard sheet to pull specific team stats. The data refreshes periodically, keeping your dashboard reasonably current.

Importing Multiple Tables into Separate Sheets

For pages with many tables, you can import each into its own sheet to stay organized:

  • Sheet "Revenue": =IMPORTHTML(A1, "table", 1)
  • Sheet "Employees": =IMPORTHTML(A1, "table", 2)
  • Sheet "Locations": =IMPORTHTML(A1, "table", 3)

Store the URL in a single cell (A1 on a config sheet) so updating the source URL changes all imports at once.

Common Mistakes

  • Getting the wrong table. Web pages often have hidden or decorative tables used for layout. The table you want might not be index 1. Try incrementing the index value until you land on the right table.
  • Pages that load data with JavaScript. IMPORTHTML can only read content present in the initial HTML response. If a site uses JavaScript frameworks (React, Vue, Angular) to render tables after page load, IMPORTHTML will return an error or empty results. There is no workaround within Google Sheets for this.
  • Exceeding the import function limit. Like IMPORTDATA and IMPORTXML, IMPORTHTML counts toward the 50-import-function cap per spreadsheet. Heavy use across many cells can hit this limit quickly, causing formulas to fail with a loading error.

SheetAI Tip

Don't want to memorize this syntax? With SheetAI, just type what you need in plain English and the formula is generated for you. Install SheetAI to try it free.

Skip the formula. Describe what you need.

SheetAI lets you type what you want in plain English and generates the perfect formula — no syntax to memorize.

Try SheetAI Free