How to convert JSON to CSV (flattening, headers, missing keys)

TL;DR: Fix delimiter/quotes first, then convert CSV to JSON locally (no upload).

JSON is flexible; CSV is a table. The conversion works best when you understand how headers are chosen and how nested fields become columns.

Start with the right input shape

Most JSON → CSV converters expect a JSON array of objects like [{"a":1},{"a":2}]. If you have a single object, wrap it in an array first, or your output will not form a table.

Flattening: what it means

Nested objects don’t map to CSV columns directly. A common approach is one-level flattening: nested keys become dotted headers (e.g. meta.role). This keeps output readable while avoiding deep recursion.

  • Good: 1-level objects with a few nested fields.
  • Watch out: arrays and deeply nested structures often become JSON strings.

Headers and missing keys

CSV needs a fixed header row. A practical rule is: use keys from early rows first, then add any new keys found later. For rows missing a key, emit an empty cell. This keeps columns stable for spreadsheets.

Practical checklist (fast)

If you’re stuck, use this quick checklist to narrow the problem before you try “random fixes”. Start by validating the input format (syntax first), then confirm shape expectations (array vs object, headers vs rows). Convert a small sample, inspect the output, and only then export the full result.

  • Validate: confirm the input is strict JSON/XML/CSV (no stray characters).
  • Confirm shape: arrays vs objects; headers vs row lengths; repeated tags vs arrays.
  • Test a sample: first 20–50 rows/items are enough to detect parsing issues.
  • Export: copy/download the output and re-check it in the consumer (script/spreadsheet/API).

This workflow is privacy-first by design: All processing happens locally in your browser. Files are never uploaded.

FAQ

Why are my nested arrays shown as “[object Object]” or JSON strings? CSV can’t represent arrays natively, so converters typically stringify them.

Is it safe to convert API responses online? Avoid uploads if responses may include tokens or customer data.

Trust note: All processing happens locally in your browser. Files are never uploaded.

Privacy & Security
All processing happens locally in your browser. Files are never uploaded.