How to get an HTML table into Google Sheets

A table on a page can go into a spreadsheet in three ways, and which one works depends on how the table was built rather than on what it holds.

To get HTML to Google Sheets, open the file so the table renders, select the visible rows, and paste them into a sheet. Sheets reads the table structure from the clipboard and splits it into cells.

That covers most of what people mean by the question. The other three routes matter when the paste misbehaves, when the file is large, or when the numbers keep changing.

An HTML table rendered in a viewer, with the rows selected ready to copy.
An HTML table rendered in a viewer, with the rows selected ready to copy.

Four ways to convert HTML to Google Sheets

Route Keeps updating Best for
Copy the rendered table, paste No One table, one time
File, Import, upload the .html No Long tables, many rows
=IMPORTHTML against an address Yes Numbers that change
Save as .csv first, then import No Messy markup Sheets chokes on

The first column is the one that decides. If the page behind the table is going to change again, only IMPORTHTML saves you from repeating the work.

Route 1: paste the rendered table

The common failure here is copying from the wrong window. A code editor gives you plain text and the whole table lands in one cell.

Open the file in a browser or in the HTML file opener first. What you select is then the table as the reader sees it.

  1. Render the page.
  2. Drag across the table, header row included.
  3. Paste into an empty sheet.
  4. Check the last column. Merged cells and nested tables are the usual place rows drift out of alignment.

Numbers formatted with currency symbols or thin spaces often arrive as text. Select the column and use Format, then Number, to force them back.

Route 2: import the file

Google Sheets accepts .html and .htm under File, then Import. It reads the markup and extracts the tables, discarding headings, images, charts and scripts.

This is the route for a table too long to select comfortably, or one that sits inside a report with other content around it.

If the page holds several tables you get them all, usually stacked in source order. Identify yours by its header row rather than by position.

The Google Sheets import dialog with an .html file selected.
The Google Sheets import dialog with an .html file selected.

Route 3: IMPORTHTML, the only live one

=IMPORTHTML takes an address and pulls a table out of the page at that address, refreshing on its own schedule.

=IMPORTHTML("https://example.com/report", "table", 1)

Three arguments. The address, the word table or list, and the index of which table on the page you want. Counting starts at 1.

Two conditions have to hold. Google fetches the page as an anonymous visitor, so it must open without a sign-in. And the address must not move, or the formula breaks.

That second condition is where most attempts fail. A page re-exported to a new file every week gives you a new address every week.

Giving the table a stable address

If the table currently lives in a file on your machine, it has no address at all, and IMPORTHTML has nothing to point at.

Paste the HTML into a NOS document and it renders as a page of its own. Share, then Share link, then Create link gives it an address. Tick Public on the web so an anonymous fetch resolves.

The share panel with Public on the web ticked, which is what an anonymous fetch needs.
The share panel with Public on the web ticked, which is what an anonymous fetch needs.

Editing the page later does not move the address, so the formula in the sheet keeps resolving to the current numbers. Turning HTML into a link is the same step seen from the other side.

Route 4: through CSV when the markup fights back

Some tables are built out of nested tables, or out of div elements styled to look like a grid. Neither imports cleanly, because there is no <table> for Sheets to find.

The fallback is to get the data into comma separated rows first, then import that. If you can edit the source, flattening it to one plain <table> is usually less work than cleaning up the mess afterwards.

Editable HTML tables covers making the table correctable in place, which is often what people actually wanted when they reached for a spreadsheet.

What gets lost, and how to choose

A sheet holds values and formatting. It does not hold the rest of the page.

  • Conditional colouring written in CSS becomes plain cells.
  • Sort controls and filters written in JavaScript do not survive.
  • Charts drawn from the table are not carried across.
  • Footnotes and captions outside the <table> element are dropped on import.

If those parts are the point of the document, converting to a sheet is the wrong direction. Keep the page and send a link to it instead, and let readers who want the raw rows copy them out themselves.

With that in mind, the choice usually resolves in a few seconds.

If you need Do this
The rows once, to do maths on them Copy the rendered table and paste
A very long table out of a report File, Import, upload the file
A sheet that stays current Publish the page, then =IMPORTHTML
Other people to read, not calculate Skip Sheets, send the page link

The last row is worth pausing on. A spreadsheet is a working surface, not a reading surface, and converting a finished report into one usually costs more than it returns.

Questions people ask

Can Google Sheets open an HTML file directly?

Yes. File, then Import, accepts .html and .htm and pulls the tables out of the markup. Everything that is not a table, headings, charts, scripts, is dropped. If the file has several tables you get all of them stacked, so check which block is the one you wanted.

Why does my pasted HTML table land in one cell?

You pasted the source code rather than the rendered table. Open the file in a browser or a viewer first, select the visible rows, then copy. Sheets reads the clipboard HTML flavour and splits it into cells. Pasting from a code editor gives you plain text instead.

What does IMPORTHTML need to work?

A web address that opens without a sign-in, because Google fetches it as an anonymous visitor. The formula is =IMPORTHTML("https://example.com/page","table",1) where the last number picks which table on the page. Private drive files and localhost paths will not work.

How do I keep the sheet in sync with the page?

Use IMPORTHTML against a stable address and edit the page rather than re-exporting it. If the address never moves, the formula keeps resolving. A pasted table is a one-time copy and goes stale the moment the source changes.

Keep reading