Xerobit

HTML Table to CSV Converter

Paste any HTML table markup into the box below to convert it to CSV format. The converter extracts rows and cells, decodes HTML entities, and outputs standard comma-separated values you can save or copy into a spreadsheet. Everything runs locally in your browser, so no data is uploaded anywhere.

Paste your HTML table source here.

Choose the character that separates columns.

CSV Output

Name,Age
Alice,30

How to use the html table to csv converter

  1. Paste your HTML table markup into the input area. You can include <thead>, <tbody>, or plain <tr> rows.
  2. Select your preferred delimiter: comma, tab, or semicolon.
  3. The CSV output appears immediately as you type or paste.
  4. Copy the result or download it to open in Excel, LibreOffice Calc, or another spreadsheet program.

How the conversion works

The converter uses a hand-written tokenizer to parse the HTML string without relying on the browser DOM. It scans for tags like <table>, <tr>, <td>, and <th>, while skipping comments, doctypes, and raw content inside <script> or <style> blocks. Text nodes are collected per cell, and HTML entities such as &amp; and ' are decoded back to their literal characters.

Once the grid of cells is built, each value is escaped according to RFC 4180. If a cell contains the chosen delimiter, a double quote, or a newline, the entire field is wrapped in double quotes and any internal double quotes are doubled. For example, the cell He said "hello, world" becomes "He said ""hello, world""" in the CSV output.

Handling colspan and rowspan

Real-world tables often use colspan and rowspan attributes to merge cells. This converter tracks occupied positions in a virtual grid. When a cell spans multiple columns, its text is placed in the first column and empty fields fill the remaining spanned columns. Rowspan works similarly: the cell text appears in the starting row, and subsequent rows receive an empty field at that column position, so the cells that follow stay in the right column. Spans are capped at 200 columns and 1000 rows.

This approach keeps the rectangular shape required by CSV files. Without it, merged cells would shift later columns out of alignment and corrupt the data structure when opened in a spreadsheet.

Common HTML entity reference

When converting an html table to csv, entities must be decoded so the resulting file contains readable text rather than markup codes. Here are the most frequently encountered entities:

EntityCharacterDescription
&amp;&Ampersand
&lt;<Less-than sign
&gt;>Greater-than sign
&quot;"Double quotation mark
&apos;'Apostrophe
&nbsp; Non-breaking space
&#39;'Numeric apostrophe

Numeric references like &#169; (copyright symbol) and hexadecimal ones like &#x00A9; are also decoded automatically during the html table to csv process.

Practical use cases

Data analysts frequently encounter tables embedded in web pages, reports, or legacy HTML emails. Copying them directly into a spreadsheet often pastes everything into a single column. Converting the html table to csv first ensures each cell lands in its own column.

Developers migrating static websites to databases can extract tabular data from old HTML files. Instead of writing custom scripts for every page, a reliable table to csv converter handles varying structures, nested tags within cells, and inconsistent whitespace uniformly.

If you need to convert other structured formats, related tools like xml to csv and yaml to csv follow the same principles for different source syntaxes. For flattening an entire page rather than just a table, html to text strips all markup. To transform tabular data into structured objects instead of flat rows, html table to json produces key-value pairs.

Edge cases and limitations

The tokenizer handles malformed markup gracefully. Unclosed tags like <td> without a matching </td> are closed implicitly when the next cell or row begins. Attributes may appear with single quotes, double quotes, or no quotes at all, and the parser accommodates each form.

However, deeply nested tables present a structural challenge. When a <table> appears inside a <td>, the converter processes only the outermost table to maintain a flat two-dimensional grid. Inner tables are treated as text content within their parent cell, with a space between their cells. Cell values that start with =, +, - or @ are copied unchanged, so a spreadsheet may read them as formulas: check data from sources you do not trust before opening the CSV. If you need to extract nested tables separately, isolate each one before running the conversion.

Very large tables with thousands of rows may take a moment to tokenize since the parsing happens synchronously in the browser. For typical web tables under a few hundred rows, the conversion is effectively instant.

Worked examples

ExampleInputResult
Simple two-column tableHTML table markup: <table><tr><th>Name</th><th>Age</th></tr><tr><td>Alice</td><td>30</td></tr><tr><td>Bob</td><td>25</td></tr></table>; Delimiter: commaName,Age / Alice,30 / Bob,25
Table with commas and quotesHTML table markup: <table><tr><th>Item</th><th>Price</th></tr><tr><td>Widget, "Deluxe"</td><td>$9.99</td></tr></table>; Delimiter: commaItem,Price / "Widget, ""Deluxe""",$9.99
Table with HTML entitiesHTML table markup: <table><tr><td>Tom &amp; Jerry</td><td>1 &lt; 2</td></tr></table>; Delimiter: commaTom & Jerry,1 < 2
Semicolon-delimited outputHTML table markup: <table><tr><td>A</td><td>B</td><td>C</td></tr></table>; Delimiter: semicolonA;B;C

FAQ

Does this tool upload my HTML to a server?

No. The conversion runs entirely in your browser using JavaScript. Your HTML markup never leaves your device.

Can I convert multiple tables at once?

This tool extracts the first complete table found in the input. If your HTML contains several tables, run each one separately to get individual CSV outputs.

Why are some cells wrapped in double quotes in the output?

According to the CSV standard, any field containing a comma, double quote, or newline must be enclosed in double quotes. Internal double quotes are escaped by doubling them.

Does it handle colspan and rowspan attributes?

Yes. Spanned cells are expanded into the appropriate number of columns or rows, filling extra positions with empty fields to keep the grid rectangular.

What delimiters are supported?

You can choose comma, tab, or semicolon. Tab-separated values are useful when your data naturally contains many commas.

Will HTML tags inside table cells break the output?

No. Tags like strong or em inside a td element are stripped, and only their text content is kept. Line breaks from br tags become spaces.

How does this differ from html to markdown conversion?

Converting an html table to csv produces flat, machine-readable rows suitable for spreadsheets. Tools like html to markdown format content for documentation with visual table syntax instead.