SmartQueryTools

HTML Table to CSV

Paste HTML containing a <table> or upload an HTML file. The first table found is extracted and downloaded as CSV. Everything runs in your browser.

or paste your HTML below

How to use the HTML Table to CSV Converter

  1. Paste HTML that contains a <table> element, or click Upload .html file to load a .html or .htm file. A full saved web page works too.
  2. Check the preview. It shows how many columns and rows were found, plus the first 5 rows.
  3. If the preview shows the wrong table, cut the HTML down to just the table you want. The tool always uses the first table in the input.
  4. Click Download CSV to save the result as table.csv.

Worked example

A table copied from a web page, with a link inside one cell and commas inside the numbers.

Input (HTML)

<table>
  <thead>
    <tr><th>City</th><th>Country</th><th>Population</th></tr>
  </thead>
  <tbody>
    <tr><td>Paris</td><td>France</td><td>2,102,650</td></tr>
    <tr><td><a href="/osaka">Osaka</a></td><td>Japan</td><td>2,752,412</td></tr>
  </tbody>
</table>

Output (table.csv)

City,Country,Population
Paris,France,"2,102,650"
Osaka,Japan,"2,752,412"

The <th> cells in <thead> become the header row. Each <tr> in the table body becomes one CSV row. Tags inside cells are removed and only the visible text is kept, so the link becomes Osaka. The population values contain commas, so they are wrapped in double quotes.

What gets kept and what gets dropped

  • Kept: the text of each cell. Line breaks and repeated spaces inside a cell become one space.
  • Kept: <th> cells used as row labels inside body rows. Both <th> and <td> cells are read.
  • Kept: rows from every <tbody>, plus <tfoot> rows at the end.
  • Dropped: links, images, styling, classes and any other markup inside cells.
  • Nested tables inside a cell do not add rows. Their text stays inside the outer cell.
  • Values are copied as text. Numbers, dates and currency symbols appear exactly as they do on the page.

Frequently Asked Questions

How do I get a table from a website into CSV?

In your browser, right-click the table and choose Inspect. Find the <table> element, right-click it, and choose Copy, then Copy outerHTML. Paste that here. You can also save the whole page as .html and upload it, but only the first table on the page is converted.

Which row is used as the header?

If the table has a <thead>, its rows are the header. Without one, any leading rows made only of <th> cells are the header, and if there are none the first row is. When there are several header rows, the labels in each column are joined, so a Q1 group over a Jan column gives Q1 Jan. Empty header cells are named column_1, column_2 and so on. Every other row is data, including rows in each <tbody> and in <tfoot>.

What happens to merged cells (colspan and rowspan)?

They are expanded so every column stays aligned. A cell with colspan="3" fills three CSV fields with the same text. A cell with rowspan="2" repeats its text in the row below. Fields to the right keep their correct columns.

Can it convert several tables at once?

No. It converts the first <table> it finds. To convert another table, paste only that table’s HTML.

Does the tool fetch a URL for me?

No. It works on HTML you paste or upload. Nothing is sent to a server, so it also works on pages behind a login once you copy their HTML.

Related tools