How to Convert HTML Tables to JSON
Last updated: 2026-04-15
HTML tables are everywhere: API documentation, government data portals, pricing pages, sports statistics. The data is right there in the DOM, but extracting it manually means a lot of copy-pasting and reformatting. Converting HTML <table> markup directly to JSON gives you structured data ready for processing.
Step-by-Step: Convert HTML Table to JSON
- Open Convertee and select HTML Table as the source and JSON as the target format.
- Paste your HTML table markup into the input panel. You only need the
<table>element and its contents, not the full page HTML. - Click Convert (Cmd+Enter).
- Copy the JSON output or download it as a file.
Parsing happens entirely in your browser using the HTML Living Standard table model. No data is sent anywhere.
Before / After Example
Input HTML:
<table>
<thead>
<tr>
<th>City</th>
<th>Country</th>
<th>Population</th>
</tr>
</thead>
<tbody>
<tr><td>Seoul</td><td>South Korea</td><td>9776000</td></tr>
<tr><td>Tokyo</td><td>Japan</td><td>13960000</td></tr>
<tr><td>Berlin</td><td>Germany</td><td>3645000</td></tr>
</tbody>
</table>Output JSON:
[
{ "City": "Seoul", "Country": "South Korea", "Population": "9776000" },
{ "City": "Tokyo", "Country": "Japan", "Population": "13960000" },
{ "City": "Berlin", "Country": "Germany", "Population": "3645000" }
]How It Works
Convertee parses the HTML using the browser's native DOMParser. It locates all <table> elements, reads <th> cells as column headers, and maps each <tr> in the body to a JSON object. If no <thead> is present, the first row is treated as the header.
Common Use Cases
- Web scraping cleanup. After scraping a page, you often have raw HTML. Converting tables to JSON gives you structured data without writing a custom parser.
- Documentation tables. API docs, specification tables, and reference pages frequently use HTML tables. Extract them as JSON for test data or configuration files.
- Government and public data. Many public datasets are published as HTML tables on .gov websites. Converting to JSON makes them consumable by modern applications.
- Competitive analysis. Pricing comparison tables, feature matrices, and benchmark results published as HTML can be converted for structured comparison.
Handling Complex Tables
- Multiple tables. If your HTML contains several tables, Convertee processes each one separately and returns an array of table results.
- Colspan and rowspan. Merged cells are expanded so that every row has the same number of columns. The merged value fills the first cell; subsequent cells receive empty strings.
- Nested HTML in cells. Tags like
<a>,<strong>, and<em>are stripped. Only the text content of each cell is included in the JSON output.
Frequently Asked Questions
- Do I need to paste the entire HTML page?
- No. You only need the <table> element and its contents. Convertee will extract tables from a full HTML document, but pasting just the table is sufficient and faster.
- How are colspan and rowspan handled?
- Merged cells (colspan/rowspan) are expanded so every row has the same number of columns. The merged value fills the first cell; remaining cells are left empty.
- Are links and formatting in table cells preserved?
- No. HTML tags like <a>, <strong>, and <em> are stripped. Only the text content of each cell is included in the JSON output. This ensures clean, structured data.