JSON to HTML Table Converter — Free Online Tool
Convert a JSON array to a styled HTML table using AI. Generates semantic <table> markup with <thead>, <tbody>, and proper <th>/<td> elements. Free, no sign-up.
JSON to HTML Table Converter — Free Online Tool
About JSON to HTML Table Converter — Free Online Tool
JSON to HTML Table converts a JSON array of objects into a formatted HTML table, automatically mapping array keys to column headers and values to table cells. Developers use it to quickly prototype data displays, generate static report markup, or embed structured data in emails and dashboards without writing boilerplate table HTML by hand.
JSON Data Type to HTML Table Cell Mapping
| JSON Type | Example Value | HTML Output | Notes |
|---|---|---|---|
| string | "Alice" | <td>Alice</td> | Rendered as plain text; HTML characters are escaped |
| number | 42 | <td>42</td> | Integers and floats rendered as-is |
| boolean | true | <td>true</td> | Serialized to lowercase string |
| null | null | <td></td> | Rendered as empty cell |
| array | [1,2,3] | <td>[1,2,3]</td> | Serialized to JSON string inline |
| object | {"x":1} | <td>{"x":1}</td> | Nested objects serialized to JSON string |
JSON to HTML Table vs Alternative Output Formats
| Format | Human Readable | Copy-Paste Ready | Sortable/Filterable | Requires JS | Best For |
|---|---|---|---|---|---|
| HTML Table | Yes | Yes | With JS (e.g. DataTables) | No | Static pages, emails, reports |
| CSV | Partial | Yes | In spreadsheet apps | No | Spreadsheet import, data pipelines |
| Markdown Table | Yes | Yes | No | No | README files, GitHub docs |
| JSON (raw) | Partial | Yes | No | No | API responses, storage |
| Excel / XLSX | Yes | No (binary) | Yes (native) | No | Business reporting, finance |
Frequently Asked Questions
How do I convert a JSON array to an HTML table in JavaScript?
You can iterate over the array with Object.keys() on the first element to build the header row, then map each object's values into <td> cells. A minimal implementation uses Array.prototype.map() to generate <tr> rows and joins them inside a <table> tag. For production use, always escape cell values to prevent XSS — replace <, >, and & with their HTML entities.
Why is my JSON not converting to a table correctly?
The most common cause is that the input is not a flat JSON array of objects — nested objects or arrays, a top-level object instead of an array, or inconsistent keys across rows all produce unexpected output. Flatten nested structures first and ensure every element in the array shares the same set of keys. Also check that the JSON is valid using a linter before passing it to the converter.
Can I convert JSON to an HTML table with CSS classes for styling?
Yes — most converters and custom implementations support injecting class attributes on the <table>, <thead>, <tbody>, <tr>, and <td> elements. Common patterns include adding class="table table-striped" for Bootstrap or class="w-full border-collapse" for Tailwind. If you are writing your own converter, accept a config object that maps element types to class strings.
How do I handle nested JSON objects when converting to an HTML table?
Nested objects and arrays cannot be natively represented in a flat two-dimensional table. The two standard approaches are: (1) serialize the nested value to a JSON string and display it in the cell, or (2) flatten the structure beforehand using a library like flat (npm) or a recursive function that produces dot-notation keys such as address.city. Choose option 2 if users need to read or sort on nested fields.
What is the difference between JSON to HTML table and JSON to CSV?
An HTML table renders directly in a browser or email client with markup for headers, rows, and optional styling, while CSV is a plain-text format suited for import into spreadsheets like Excel or Google Sheets. HTML tables support inline styling, hyperlinks, and colspan/rowspan; CSV supports none of these. Use HTML tables when the output will be embedded in a webpage or email, and CSV when the data needs further analysis in a spreadsheet tool.
If jsondecode.com saved you time, share it with your team
Free forever. No ads. No sign-up. Help other developers find it.