Render Fictional JSON Records as an HTML Table

Convert a small JSON array to an escaped HTML table and verify headers and cells before embedding the markup elsewhere.

By DevSphere Editorial · · 5 min read

Open Converter

Use a flat array for a table

A short array of records can be easier to review as an HTML table than as nested JSON. The Format Converter supports JSON as input and HTML Table as an output. Its HTML generator gathers keys from object records, writes table headers and rows, and escapes ampersand, angle brackets, and quotation marks in header and cell text. It produces markup only; it does not display a rendered preview, add styling, sanitize every browser-sensitive context, or publish the table. Use fictional, flat records with a consistent shape. The example has a label that includes an ampersand to demonstrate escaping. Keep the output in a safe preview or local test before embedding it. An HTML table is a presentation format, not a durable data interchange representation.

[
  {"code": "CARD-1", "label": "Demo & sample", "count": 2},
  {"code": "CARD-2", "label": "Plain item", "count": 5}
]

Select the supported direction

Open Format Converter. In From, choose JSON, then select HTML Table in To. The available output list depends on the selected source format; JSON supports XML, CSV, YAML, TSV, String, and HTML. Paste the array in the input panel. The conversion result updates as the input and format selections change, so there is no separate Run button. The output panel should contain a table element with a header row for code, label, and count and two body rows. Use the character count only as a rough display aid. If you need a baseline, Load Sample inserts the converter's sample for the selected input format; replace its values with the synthetic example to keep the review controlled.

Inspect escaping and column order

Check that the header labels and both records appear in the generated markup. The ampersand in Demo & sample should be serialized as & so the browser interprets it as text rather than markup. The converter collects unique headers from object entries in first-seen order; if records have different keys, it may render a union of those headers and blank cells where an item lacks a key. Nested values are stringified as JSON for display, not expanded into subcolumns. A primitive array or irregular shape may not create meaningful table columns. The output uses basic table attributes and does not include CSS, accessibility review, responsive design, or sorting controls. Decide whether this is suitable for a quick static report rather than assuming it is a complete component.

<table border="1" cellpadding="5" cellspacing="0">
  <thead><tr><th>code</th><th>label</th><th>count</th></tr></thead>
  <tbody>
    <tr><td>CARD-1</td><td>Demo &amp; sample</td><td>2</td></tr>
    <tr><td>CARD-2</td><td>Plain item</td><td>5</td></tr>
  </tbody>
</table>

Handle output as markup, not trusted content

The helper escapes common characters in cell and header text, which is an important basic protection when representing text in an HTML text context. Still, the output has not been reviewed for every context in which markup might be embedded, and generated HTML can be unsafe if later inserted in a different context or modified. Do not feed real untrusted data into a page without following the application's HTML safety practices. The converter does not sanitize a complete HTML document, validate a content security policy, or inspect URLs. Copy is available beside the output, but copying code is not the same as rendering it safely. If you need a production report, use a templating system with context-aware escaping and review the resulting page in the actual application.

Verify or troubleshoot the conversion

If output says to fix input errors, confirm that JSON is a complete array with double-quoted keys and values and no trailing comma. A malformed record prevents conversion. Once successful, verify two data rows, three headers, and the escaped ampersand. If the columns look incomplete, check whether keys occur only after the first object or whether values are nested. The converter has no template editor, CSS panel, or HTML preview. It also does not preserve JSON types in the table because the output is text markup. Keep the original JSON and compare it with the rendered rows. For accessible or data-sensitive reports, use a reviewed application component rather than pasting generated markup directly into a public page. Clear the input before trying another sample.

A nested record needs a deliberate display decision. The table helper turns an object-valued cell into JSON text, so a group of labels appears as one cell instead of a second-level table. That may be acceptable for a debugging snapshot but difficult for readers to scan. Missing keys in later objects create blank cells, while headers are collected from object records in first-seen order. Before embedding the markup, check whether row order is stable and whether empty values should be distinguishable from absent fields. If the table is only for a quick handoff, add a note identifying the sample and its limits. For an application view, build an accessible component that defines captions, header scope, empty-state behavior, and escaping rules for its actual context.

For this sample, count the header cells and body rows explicitly: three headers and two records. Then inspect the literal output, not only its visible text, to see that ampersand becomes an entity and that the table tags are balanced. HTML text escaping is context-specific; a value safe in a text node is not automatically safe in an attribute, script, style, or URL context. The generator writes values into table text locations, but later edits may move them elsewhere. Keep a generated snippet isolated in a trusted preview and do not concatenate it into a larger page without reviewing the insertion point. When accessibility matters, test with keyboard navigation and a screen reader in the real component rather than assuming a basic thead and tbody are sufficient.

Browse all tutorials