Convert an HTML table to CSV or JSON

Paste HTML that contains a table and get the same data as CSV, ready for Excel or Google Sheets, and as JSON, with merged cells expanded and commas and quotes escaped correctly.

Live demo · real result from this tool

CSV

Region,Q1,Q2
"North, East","1,200","1,450"
South,Not reported,
"West ""Coast""",980,"1,105"

JSON

[  {    "Region": "North, East",    "Q1": "1,200",    "Q2": "1,450"  },  {    "Region": "South",    "Q1": "Not reported",    "Q2": ""  },  {    "Region": "West \"Coast\"",    "Q1": "980",    "Q2": "1,105"  }]

Processed on your device — nothing is uploaded.

How to use HTML Table to CSV

  1. Paste HTML into the HTML box. It can be a single table or a whole page.
  2. If the HTML has more than one table, enter the Table number (when there are several). Table 1 is the first one in the code.
  3. Tick Repeat merged (colspan/rowspan) values in every cell if you want no gaps.
  4. Leave First row is the header (for JSON keys) ticked to get JSON objects; untick it to get arrays.
  5. Copy or download the CSV (table.csv) or the JSON (table.json).

What it does and when to use it

Copying a table straight from a web page into a spreadsheet often goes wrong: cells merge, numbers with commas split into two columns, or the whole row lands in one cell. Working from the HTML avoids that. The tool reads the real rows and cells, so the CSV has exactly one line per table row and every value stays in its own column.

Use it for tables in reports, documentation pages, exported web pages or old HTML emails, and for feeding table data into a script as JSON. To turn the CSV into a table for a README, use CSV to Markdown. To go the other way and build a table from rows of text, use the HTML Table Generator.

How it works

The HTML is parsed in your browser and each table is turned into a grid. Header cells (th) and data cells (td) are treated the same. A cell with colspan="2" takes two positions in its row, and a rowspan cell reserves its position in the rows below, so later cells land in the right column. Each cell’s text is then CSV-escaped and the rows are joined with Windows line endings (CRLF), which every spreadsheet accepts.

For JSON, the first row supplies the keys. An empty header cell becomes column1, column2 and so on.

Worked examples

The sample sales table. It has a comma in “North, East”, thousands separators, a colspan="2" cell and a name with quotes. The CSV is:

Region,Q1,Q2
"North, East","1,200","1,450"
South,Not reported,
"West ""Coast""",980,"1,105"

Repeating merged values. With the repeat option ticked, the South row becomes South,Not reported,Not reported, and its JSON object gets "Q2": "Not reported" instead of an empty string.

Picking the second table. HTML with a people table and a second table captioned “Pets”, with Table number set to 2, gives the CSV Pet / Cat and the note Found 2 tables; showing table 2 (“Pets”).

Limits and tips

  • A table nested inside another table counts as a separate table.
  • Numbers stay text exactly as written, including currency signs and separators, so 1,200 is not changed to 1200.
  • If the table is built by JavaScript, the page source may not contain it. Copy the rendered HTML from the developer tools instead.
  • To clean the table’s markup before converting, run it through the HTML Cleaner.

Frequently asked questions

How do I get a table from a website into this tool?
Right-click the table in your browser, choose Inspect, then right-click the table element in the developer tools and pick Copy, then Copy outerHTML. Paste that here. Saving the whole page source also works; pick the table by its number.
Why are some values wrapped in double quotes?
CSV uses commas to separate columns, so any cell that contains a comma, a double quote, a line break, or a space at the start or end is put in quotes, and quotes inside it are doubled. Spreadsheet programs read this back as the original text, so 1,200 stays one cell.
What happens to merged cells?
A cell with colspan or rowspan fills every grid position it covers, so the cells after it stay in the right column. By default the extra positions are left empty. Tick "Repeat merged values in every cell" to copy the value into each of them, which is easier to filter and sort.
Are links and formatting kept?
No. Each cell becomes plain text on one line, without bold or links; an image is replaced by its alt text in square brackets. If you need the link addresses, list them with the HTML Attribute Extractor.
Why does Excel show odd characters for € or accents?
Some versions of Excel open CSV files in an older encoding. Use Data, From Text/CSV and choose UTF-8, or paste the CSV into Google Sheets, which reads UTF-8 by default.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close