JSON to HTML Table

Convert JSON arrays to styled HTML table markup. Optional inline CSS included.

What is JSON to HTML Table Conversion?

Converting a JSON array to an HTML table turns structured data into a visual table that can be embedded directly in web pages, emails, or CMS content. Each JSON object in the array becomes a table row, and the object keys become column headers — no template code required.

This is useful for building data dashboards, generating reports that include tabular data, inserting dynamic content into email templates, creating documentation pages from API responses, or producing quick visual summaries of database exports.

JSON to HTML Table Example

json
[
  { "name": "Alice", "score": 95, "grade": "A" },
  { "name": "Bob",   "score": 82, "grade": "B" }
]

Generates:

html
<style>
table { border-collapse: collapse; width: 100%; font-family: sans-serif; }
th, td { border: 1px solid #ddd; padding: 8px 12px; text-align: left; }
th { background: #f5f5f5; font-weight: 600; }
tr:nth-child(even) { background: #fafafa; }
</style>
<table>
  <thead>
    <tr><th>name</th><th>score</th><th>grade</th></tr>
  </thead>
  <tbody>
    <tr><td>Alice</td><td>95</td><td>A</td></tr>
    <tr><td>Bob</td><td>82</td><td>B</td></tr>
  </tbody>
</table>

XSS Safety

All cell values are HTML-escaped: &, <, >, and " are replaced with their HTML entity equivalents. This prevents XSS when rendering untrusted data.

Common Uses

  • Email reports and digestsTurn a JSON export into a table for a transactional or scheduled report email, where a real <table> is still the most reliable layout tool.
  • CMS and documentation pagesPaste a data table directly into a CMS's HTML block or a static site's markdown-with-HTML content.
  • Quick data dashboardsRender an API response as a readable table for an internal tool without building a full frontend component for it.
  • Turning an API response into documentationShow example response data as a formatted table in API docs instead of a raw JSON block.

Making the Table Responsive

A generated table with many columns can overflow a narrow viewport. The standard fix is wrapping it in a scrollable container rather than trying to shrink every column: <div style="overflow-x: auto">...table...</div>. This keeps the table's columns readable at their natural width and lets the wrapper scroll horizontally on small screens, instead of squeezing text until it wraps awkwardly or becomes illegible.

Frequently Asked Questions

Yes — inline the CSS as style attributes on each element, as email clients strip <style> blocks. Use the table structure and add style= to each th and td.

Paste the HTML into your component template (dangerouslySetInnerHTML in React, or [innerHTML] in Angular). Ensure the source JSON is trusted.

Uncheck 'Include CSS styling' in the toolbar to get a bare <table> element you can style yourself.

Nested objects are JSON.stringify'd into the cell. Flatten your JSON first using the JSON Flatten tool for cleaner output.

Wrap the generated <table> in a container with overflow-x: auto so it scrolls horizontally on narrow screens instead of squeezing columns unreadably or breaking the page layout.

Most major email clients (Gmail, Outlook) strip <style> tags or scope CSS unpredictably for security and rendering-consistency reasons. Inline the same styles as a style= attribute directly on each <table>, <th>, and <td> element instead for reliable rendering across clients.

Related Tools