How to convert an HTML table to CSV
CSV is the simplest way to move tabular data between tools: spreadsheets, databases, scripts. Turning a table from a web page into a CSV file that opens correctly everywhere has a few traps, though.
The usual traps
- The separator. In the United States, CSV files use a comma. In France, Germany and many other countries, Excel expects a semicolon, because the comma is the decimal separator. A file with the wrong separator opens with everything in column A.
- Accented characters. Without the right encoding marker, Excel can show "é" instead of "é".
- Commas and quotes inside values. A value such as
Paris, Francemust be quoted, or it splits into two columns. - Merged cells. A cell that spans several rows or columns must be repeated, or every following column shifts.
Method 1: through a spreadsheet
- Copy the table from the page and paste it into Excel, Numbers, LibreOffice or Google Sheets.
- Check that each value sits in its own cell.
- Use File > Save as (or Download > CSV in Google Sheets) and choose the CSV format.
This works well for small tables. Check the separator your spreadsheet uses before sending the file to someone in another country.
Method 2: with a script
If you program, libraries such as pandas in Python can read the tables of a page:
import pandas as pd
tables = pd.read_html("https://example.com/page")
tables[0].to_csv("table.csv", index=False)
This is ideal for automation, but it only sees tables present in the page's HTML, not those built by JavaScript or behind a login.
Method 3: export straight to CSV with TableSnap
- Open the page in Chrome and click the TableSnap icon (or press Alt+Shift+T).
- Pick the table in the list.
- Click CSV: the file downloads immediately.
The file is written to the RFC 4180 standard: values containing commas, quotes or line breaks are quoted correctly, merged cells are expanded, and a UTF-8 marker keeps accented characters readable in Excel. By default, the separator follows your system's language, so the file opens in the right columns on your computer.
CSV export is free up to 500 rows per table; the Pro license removes the limit and lets you choose the separator yourself. Everything runs locally in your browser.
Summary
- Small table, occasional need: paste into a spreadsheet, then save as CSV.
- Repeated, automated extraction: a script.
- Any table you can see, in one click, with a file that opens correctly: TableSnap.