Convert HTML Table to JSON Online
Extract an HTML table into JSON, with the header cells as keys. The markup is read in your browser and never uploaded.
Drop a CSV or Excel file here
CSV · XLSX · XLS · XLSM · XLSB
Ready to download as a binary file.
How to convert an HTML table to JSON
Three steps from clubs.html to JSON.
1. Paste the HTML
Paste markup that contains a <table>, or drop an .html file.
2. Check it in the grid
Check the header row: the <th> text becomes the keys, spaces included ("Avg attendance").
3. Pick a shape and copy
Choose a shape and an indent, then copy the JSON or download data.json.
Example: HTML in, JSON out
A table copied from a wiki-style page, with a link, a footnote in <sup> and thousands separators.
<table class="wikitable">
<thead><tr><th>Pos</th><th>Club</th><th>Avg attendance</th></tr></thead>
<tbody>
<tr><td>1</td><td><a href="/rovers">Rovers</a><sup>[a]</sup></td><td>41,250</td></tr>
<tr><td>2</td><td>United</td><td>38,900</td></tr>
</tbody>
</table>[
{
"Pos": 1,
"Club": "Rovers[a]",
"Avg attendance": "41,250"
},
{
"Pos": 2,
"Club": "United",
"Avg attendance": "38,900"
}
]The footnote is part of the club's text ("Rovers[a]"), and 41,250 stays a string because of the comma. Fix both in the grid if you need clean names and numbers.
What changes between HTML and JSON
Numbers and text
A cell that parses as a number is written as a JSON number, anything else as a string. Here Pos comes out unquoted.
Empty cells
An empty cell becomes an empty string (""), never null.
Other shapes
Keyed Object uses the first column (Pos) as the key of each entry and leaves it out of the value. JSONLines writes one object per line, which suits streaming tools and log pipelines.
First row is the header
The first row (Pos, Club and Avg attendance) becomes the header, whether its cells are <th> or <td>. colspan and rowspan would not be expanded, so check spanned rows in the grid.
When to convert HTML to JSON
- Pulling a table out of a saved web page for a script or an app.
- Turning an old HTML report into structured data.
HTML to JSON in JavaScript
TabularJS reads HTML: every <table> becomes a worksheet. Then each row is zipped with the header into an object.
import tabularjs from 'tabularjs';
// The first row of the table becomes the column titles
const { worksheets } = await tabularjs('clubs.html', { tableIndex: 0 });
const header = worksheets[0].columns.map((col) => col.title);
const rows = worksheets[0].data;
const records = rows.map((row) =>
Object.fromEntries(header.map((key, i) => [key, row[i] ?? '']))
);
console.log(JSON.stringify(records, null, 2));TabularJS differs from this page in two ways: it returns every <table> as a worksheet, and it turns colspan into mergeCells.
Frequently asked questions
Can I give it a URL?
No, the page doesn't fetch URLs. Save the page or copy its HTML and paste it. In code, fetch the HTML yourself and pass the string to TabularJS.
Can I pick a table other than the first?
Paste only the table you want. In code, TabularJS takes { tableIndex: 1 } for the second table, or returns every table if you leave the option out.
Can I paste a whole web page?
Yes. The page looks for the first <table> in what you paste and ignores everything else. For a specific table, copy just that element (Inspect > Copy > Copy outerHTML).
Can I get null instead of empty strings?
Not from this page: empty cells are always written as "". If your code needs null, convert while parsing: JSON.parse(text, (key, v) => (v === '' ? null : v)).
Does clubs.html get uploaded when I convert it to JSON?
No. The markup is read in your browser and never uploaded.