How to convert JSON to an HTML table
To convert json to an html table, paste an array of objects. Each object becomes a row, and each key becomes a column. The tool collects the keys from every object, so a key that appears in only some rows still gets its own column. Take this JSON:
[{"name":"Ada","age":36},{"name":"Linus","age":55}]With Bare HTML and the caption People, the result is:
<table>
<caption>People</caption>
<thead>
<tr>
<th scope="col">name</th>
<th scope="col">age</th>
</tr>
</thead>
<tbody>
<tr>
<td>Ada</td>
<td>36</td>
</tr>
<tr>
<td>Linus</td>
<td>55</td>
</tr>
</tbody>
</table>The status line reads 2 rows and 2 columns. Values are escaped, so a string such as <b> is shown as text and never becomes markup in your page.
Which part of the JSON becomes the table
A real API response is usually an object that wraps the list, such as a status field next to an array called data. When the object has exactly one list of objects, or one under a common name such as data, items, results or rows, that list is used and a note says so. To pick another part, type a path in More options under Rows from, for example data.items or results[0].rows.
- An array of objects gives one row per object.
- An array of arrays gives one row per inner list. If the first list is all text and there is more than one list, it becomes the header row.
- An array of plain values gives a single column named value.
- One object gives a two-column table of keys and values.
- An object whose values are all objects gives one row per key, with the key in a first column named key.
- JSON Lines, one JSON value per line, is read as an array.
Nested objects and lists: sub-tables, columns or JSON text
Most JSON found online is nested, and a table cell can hold only one thing. The Nested data setting gives three ways to handle it. Here is one row with an address object, a list of tags and a list of orders:
[{"id":1,"address":{"city":"London","zip":"N1"},"tags":["a","b"],"orders":[{"sku":"X","qty":2},{"sku":"Y","qty":1}]}]Sub-tables and lists writes the address as a small two-column table, the tags as a bullet list and the orders as a table with sku and qty columns, all inside the cell:
<td><table><tbody><tr><th>city</th><td>London</td></tr><tr><th>zip</th><td>N1</td></tr></tbody></table></td>
<td><ul><li>a</li><li>b</li></ul></td>
<td><table><thead><tr><th>sku</th><th>qty</th></tr></thead><tbody><tr><td>X</td><td>2</td></tr><tr><td>Y</td><td>1</td></tr></tbody></table></td>Flatten into columns keeps the table flat. The columns become id, address.city, address.zip, tags, orders.0.sku, orders.0.qty, orders.1.sku and orders.1.qty. A list of plain values such as the tags is joined with commas into one cell. Keep as JSON text writes the nested value as escaped JSON, which is the simplest and the least readable. Nesting deeper than six levels in sub-table mode, or twenty in flatten mode, is written as JSON text.
JSON to HTML table for email, with inline styles
Many email programs drop a style block from a message, and a bare table then shows no borders. The Email, inline styles preset puts the styling on every tag, so the table does not depend on a style block. The first body row of a two-column table looks like this:
<tr>
<td style="border:1px solid #d0d5dd;padding:8px 12px;text-align:left;">Ada</td>
<td style="border:1px solid #d0d5dd;padding:8px 12px;text-align:right;">36</td>
</tr>If you build the message in an automation or a mail-merge tool, paste the code into the HTML part of the body. Email programs differ, so send yourself a test message first. No converter can promise how every program will draw a table.
Styles, headers and number alignment
Bare HTML writes only the table, for a site that has its own CSS. Simple CSS adds a short style block with borders and padding, and Striped CSS shades every other row. The block uses a class name, data-table by default, so it does not affect other tables on the page. You can change the class name under More options.
- Header row writes the keys inside thead with scope=col, which screen readers use to announce each column.
- First column is a row header writes the first cell of each row as th with scope=row, which suits tables where each row has a name.
- Right-align numbers aligns a column on the right when every value in it is a JSON number. A column that mixes numbers and text stays left-aligned.
- Null values can be an empty cell, the word null or a dash. A key that is missing from a row is always an empty cell.
- Columns takes a comma list such as id, name to keep only those columns, in that order.
When the JSON does not parse
If the JSON is invalid, the output panel shows the line and column of the first problem and, where the cause is common, a hint such as a missing comma or a single-quoted string. Allow comments and trailing commas in More options reads JSON5-style input by ignoring comments and a comma before a closing bracket. Single quotes and unquoted keys are not accepted.
Numbers are read as ordinary 64-bit floating point numbers. An integer with more than 15 digits, such as a long ID, may lose its last digits, and the tool adds a note when it sees one. Store such IDs as strings in the JSON to keep them exact.
Limits and what stays on your device
A table can have at most 200,000 rows, 2,000 columns and 1,000,000 cells. Past that, the tool tells you to narrow the data with Rows from or Columns. The preview shows the first 200 rows, while Copy and Download include every row.
Your JSON is read and turned into HTML in this browser tab. It is not sent to a server. The preview runs in a sandboxed frame that cannot run scripts. See the Privacy Policy for how the site handles data.
Related tools
To go the other way, HTML Table to JSON reads a table from HTML and returns typed JSON. For spreadsheet data, CSV to HTML Table builds the same kind of table from CSV, and HTML Table to CSV extracts one. JSON to Excel writes a workbook instead, and JSON Lines Viewer is a better fit for large logs.