EthicalFusion

HTML Table to CSV

Pull the data out of an HTML <table> and get clean CSV.

Was this tool helpful?

Thanks for the feedback!

Paste HTML that contains a table and this tool reads its rows and cells into CSV, ready for Excel, Google Sheets or a script. It suits anyone who needs data from a web page, a saved report or an email template in a spreadsheet without retyping it or fighting messy copy-and-paste formatting.

Getting the HTML of a table

The input must be HTML markup, not the visible text of the page. The most reliable way to get it:

  1. Open the page in Chrome, Edge or Firefox, right-click inside the table and choose Inspect.
  2. In the Elements panel, click the line that starts with <table (move up from the highlighted cell if needed).
  3. Right-click it and choose Copy › Copy outerHTML (in Firefox, Copy › Outer HTML).
  4. Paste into the input box and click Extract CSV.

You can also paste a whole page's source. The tool uses the first <table> it finds, so trim the HTML down if the table you want is not the first one.

Example

Input:

<table>
  <tr><th>Name</th><th>City</th></tr>
  <tr><td>Asef</td><td>Mumbai,
      MH</td></tr>
  <tr><td>Riya</td><td><a href="/pune">Pune</a></td></tr>
</table>

Output:

Name,City
Asef,"Mumbai, MH"
Riya,Pune

The line break and extra spaces inside "Mumbai, MH" were collapsed to a single space, the value was quoted because it contains a comma, and the link was reduced to its text. The Rows counter shows how many rows were extracted.

What is extracted and what is lost

  • Header (th) and data (td) cells are both read, row by row, whether or not the table uses thead and tbody.
  • Only text is kept: link addresses, images and their alt text, and all formatting are dropped.
  • A <br> inside a cell adds no space, so "Line one<br>Line two" becomes "Line oneLine two". Replace line-break tags with a space before converting if that matters.
  • Cells using colspan or rowspan count as one cell, so later values in that row shift left. Fix the columns in your spreadsheet, or add empty cells to the HTML first.
  • A table nested inside another table is read together with its parent, which duplicates text. Copy the inner table on its own instead.
  • Rows hidden with CSS are still included, because the tool reads the markup, not what is displayed.

Where the data goes next

Save the result as a .csv file or paste it into a sheet. Turn it into a proper workbook with the CSV to Excel Converter, or rebuild a cleaner table with CSV to HTML Table. Before reusing data from someone else's website, check that its terms allow it. The HTML is parsed by your own browser, and nothing you paste is sent to a server.

Frequently asked questions

How do I copy the HTML of a table from a website?
Right-click the table, choose Inspect, select the table element in the Elements panel, then use Copy and Copy outerHTML. Paste that into the tool.
The page has several tables. Which one is converted?
The first table in the pasted HTML. Paste only the table you need, or delete the earlier tables from the input.
Why are two words joined together in one cell?
The cell used a br tag for a line break, which adds no space when the text is read. Replace br tags with spaces in the HTML and convert again.
Why are my columns shifted in some rows?
Those rows contain merged cells using colspan or rowspan, which are read as a single cell. Add empty cells or fix the rows in your spreadsheet.
Are links kept in the CSV?
Only the visible link text is kept. The link addresses are not included.

Related tools

People also used

Embed this tool on your site

Paste it into any blog or website. Free, with a credit link.