IMPORTHTML function

Fetches HTML tables or lists from a webpage and returns them as a 2D array, useful for importing public data without manual copying.

=IMPORTHTML(url, query, index)

Generate a IMPORTHTML formula

Describe what you need. The generator will reach for IMPORTHTML where IMPORTHTML is the right tool, and tell you when it is not.

How to get a better answer
  • Name your columns by letter and by header: "column F (Net Value)" beats "the amount column".
  • State every condition, including the negatives — "not cancelled" changes the formula's shape.
  • Say where the data starts if it is not row 1, and whether it will grow.
  • Check the settings above match your spreadsheet: the wrong argument separator is a syntax error on your machine.

Arguments

How IMPORTHTML reads its arguments
urlrequiredqueryrequiredindexrequiredIMPORTHTML
ArgumentRequiredDescription
urlRequiredA string (in quotes) pointing to a public webpage; the URL must be accessible without authentication, or the function returns #N/A.
queryRequiredEither "table" to extract HTML tables or "list" to extract HTML lists; any other value returns #VALUE!.
indexRequiredA positive integer starting at 1, selecting which table or list to import from the page; exceeding the available count returns #N/A.

Returns

A 2D array of the extracted table or list data, with rows and columns preserved from the source HTML.

Availability

Excel: Not available · Google Sheets: Supported

Worked examples

1. Import the complete employee roster table from a public page

Employee IDNameDepartmentHire DateSalaryStatus
E001Alice JohnsonSales2022-03-1565000Active
E002Bob SmithEngineering2021-06-2085000Active
E003Carol LeeMarketing2023-01-1072000Active
E004David BrownSales2020-11-0568000Inactive
E005Eve WilsonEngineering2022-08-1292000Active
=IMPORTHTML("https://hr.example.com/roster", "table", 1)

Result: A 6×6 array containing the full roster with headers and all employee records.

IMPORTHTML fetches the first (index 1) HTML table from the URL. The query type "table" tells it to look for <table> elements. All rows and columns from that table are preserved, including headers.

2. Extract a specific department's employee list when multiple tables exist on the page

NameSalaryStatus
Alice Johnson65000Active
David Brown68000Inactive
=IMPORTHTML("https://hr.example.com/departments", "table", 3)

Result: A 3×3 array containing only the Sales department table from index 3 of the source page.

When a webpage contains multiple tables (Sales, Engineering, Marketing), the index parameter selects which one to import. Index 3 retrieves the third table. This avoids manually copying data across tabs and instantly syncs updates.

3. Import a bulleted list of employee names as a single-column array

Employee Names
Alice Johnson
Bob Smith
Carol Lee
David Brown
Eve Wilson
=IMPORTHTML("https://hr.example.com/names", "list", 1)

Result: A 6×1 array with the header and five employee names, one per row.

The query type "list" extracts HTML lists (typically <ul> or <ol> elements) instead of tables. IMPORTHTML converts the list into a vertical array suitable for use with VLOOKUP or filtering functions.

Common errors

Which IMPORTHTML error are you seeing?
IMPORTHTML returned an error#N/A
Verify the URL is correct and publicly accessible by pasting it into a browser. Double-check that the index number doesn't exceed the count of tables or lists on that page.
#VALUE!
Correct the query to either "table" or "list". Common mistakes: "TABLE" (uppercase), "table " (trailing space), or "row" (invalid keyword).
#REF!
Ensure the URL is wrapped in quotes and uses proper HTTP or HTTPS protocol. Check that the source website allows automated fetching; some sites block bots to prevent scraping.
ErrorWhy it happensHow to fix it
#N/AThe URL is unreachable (network error, 404, or requires authentication), or the query/index combination doesn't exist (e.g., asking for table 5 when only 3 tables are on the page).Verify the URL is correct and publicly accessible by pasting it into a browser. Double-check that the index number doesn't exceed the count of tables or lists on that page.
#VALUE!The query parameter is misspelled or invalid — it must be exactly "table" or "list" (case-sensitive lowercase, in quotes).Correct the query to either "table" or "list". Common mistakes: "TABLE" (uppercase), "table " (trailing space), or "row" (invalid keyword).
#REF!The URL string is malformed (e.g., missing quotes, invalid characters, or circular reference to the current cell) or the server rejects the request due to CORS restrictions.Ensure the URL is wrapped in quotes and uses proper HTTP or HTTPS protocol. Check that the source website allows automated fetching; some sites block bots to prevent scraping.

Tips and when to use something else

  • Use IMPORTRANGE to fetch data from another Google Sheet; use IMPORTHTML for external websites. Both return arrays but pull from different sources.
  • The index parameter starts at 1 (not 0) — the first table on a page is index 1, the second is index 2, and so on.
  • IMPORTHTML only fetches static HTML; it cannot run JavaScript or retrieve data from dynamic, client-side rendered pages. For those, consider using an API or IMPORTXML with REST endpoints.
  • Google Sheets rate-limits IMPORTHTML; if your sheet refreshes the same URL too frequently, you may hit quota limits. Add delays using column formulas or scheduled imports to avoid throttling.

Frequently asked questions

Can IMPORTHTML import data from a password-protected page or API that requires authentication?
No. IMPORTHTML only works with publicly accessible URLs that require no login or credentials. For authenticated APIs, use a Google Apps Script wrapper or a third-party connector that handles OAuth.
Why does IMPORTHTML return #N/A even though the URL works in my browser?
The most common cause is that the page requires JavaScript to render (client-side rendered). IMPORTHTML fetches raw HTML and cannot execute scripts. Inspect the page source (Ctrl+U) to check if your target table is present in static HTML. If not, the site likely uses dynamic rendering.
How often does IMPORTHTML refresh data, and can I control the refresh interval?
IMPORTHTML refreshes automatically when the sheet recalculates (when you edit a cell, open the sheet, or on Google's background refresh cycle). You cannot manually set a refresh interval, but you can use IMPORTHTML inside a formula-driven app with Apps Script for finer control.
Can I combine IMPORTHTML with QUERY or FILTER to sort or filter the imported data?
Yes. Wrap IMPORTHTML in QUERY or FILTER to refine results. For example, =QUERY(IMPORTHTML(url,"table",1),"select * where A > 100") imports a table and filters rows. This keeps your data live and avoids manual manipulation.

Need a different formula?

The full generator is not scoped to one function — describe any spreadsheet problem and it will pick.

Open the formula generator

Reviewed 2026-09-17