Skip to content
ZeroServer.tools

HTML Table to JSON

Convert HTML table markup to JSON or CSV — handles thead, th, colspan headers, and type coercion.

or drop a file here
JSON output · 3 rows
Output updated — 331 characters

Preview

NameRoleCountryActive
Alice ChenFrontend EngineerCanadatrue
Bob MüllerBackend EngineerGermanyfalse
Carlos RiveraDevOpsMexicotrue

How HTML table parsing works

The parser locates the first <table> element using a regex tokenizer — no DOM required. It extracts <tr> rows, then pulls cell content from<th> or <td>tags, stripping inner HTML and decoding common HTML entities. With "First row is header" enabled, column names come from the first row; otherwise generic column_N keys are used.

Type coercion converts numeric strings to numbers, "true"/"false" to booleans, and empty cells to null. For the reverse conversion see JSON to Table. To parse CSV see CSV to JSON.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Scraping a table from a page into structured data for analysis.
  • Turning documentation's reference table into a fixture.
  • Extracting a price or spec table for further processing.
  • Getting a table's contents out of a saved page.
  • Converting a table into JSON to diff against an API response.

Frequently Asked Questions

How are keys chosen?
From the header row — each `<th>` becomes a property name on every row object. Without a header row the columns fall back to positional keys, which is why marking headers properly in the source markup pays off here.
What happens to duplicate header names?
A JSON object cannot hold the same key twice, so two identically-named columns collapse into one and the later value wins. Rename the columns in the source, or take the array-of-arrays output, which preserves every column.
Are colspan and rowspan handled?
They are the hard case in any table parser, because a spanning cell shifts every column index after it and for several rows. Check the output against the rendered table whenever the source uses merged cells.
Does it keep formatting inside cells?
No — the text content is extracted, so a cell containing a link or bold text yields the plain string. That is nearly always what you want from a data table; markup would have to be escaped into the JSON to survive.
Are numbers converted?
Cell values come out as strings, because a table has no type information and guessing wrongly is worse than not guessing. A leading-zero product code or a phone number would be corrupted by automatic conversion.
Can I paste a whole page?
Yes — the tables are found within the markup you provide, so you do not have to isolate the table by hand first. Extra page content around it is ignored.

Common errors and gotchas

  • Expecting merged cells to convert, since rowspan and colspan have no clean object equivalent.
  • Assuming the first row is a header when the table uses none.
  • Coercing types too eagerly, so a version string or a leading-zero code becomes a number.
  • Losing nested markup inside cells, where a link's target may have been the data you needed.
  • Converting a layout table, which produces a structured version of something that was never data.

Related Converters tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate