Flatten nested JSON to dot-paths
Turn nested structures into a single-level object with dot, slash, or underscore separators. Round-trip back to nested with one click.
{
"user.name": "Ada",
"user.address.city": "London",
"user.address.country": "UK",
"user.tags.0": "admin",
"user.tags.1": "founder"
}How to flatten and unflatten JSON
Flatten turns {"a":{"b":1}} into {"a.b":1} — convenient for spreadsheets, env vars, or feature flag stores. Unflatten reverses it cleanly.
- 01
Paste nested JSON (or flat)
Drop in either shape — toggle Flatten or Unflatten depending on direction.
Inputs parse through the native
JSON.parsereviver chain — strict RFC 8259. Any syntax error returns line and column for the exact offending byte.nestedflatRFC 8259JSON.parsestrictinput · raw.json · RFC 8259{"a":{"b":1}}loaded · parsed RFC 8259RFC 8259 · ready - 02
Pick separator
Dot (default), slash, or underscore. Useful when downstream tooling reserves certain characters.
Indent options run through
JSON.stringify(value, null, n); the second argument lets you sort, transform, or omit keys via a replacer if you ever wire one in.. / _indentJSON.stringifyliveorderedseparator · optionsdot · live{"a.b": 1}options applied · livelive - 03
Arrays kept
Arrays flatten with numeric indexes:
tags.0,tags.1. Round-trip is lossless.Large documents stream through a
useMemowith stable hashing so options re-apply instantly — no full re-parse if only formatting changes.arraysindexmemoisedinstantdiff-friendlyarrays · renderedindexes · ready{"tags.0":"a","tags.1":"b"}rendered · livediff-friendly - 04
Copy or download
Swap mode sends the output back as input — handy for verifying round-trip equivalence.
Download is a
Blobwithapplication/json; copy uses the Async Clipboard API. Both round-trip identically to what the page rendered.round-tripverifyclipboardblob.jsonexport · copiedready · done✓ Copied
shipped · ready to shipsuccess
Production-grade JSON, the right way
Stick to RFC 8259
Strict JSON has no NaN, Infinity, comments, or trailing commas. If you need those, look at JSON5 or JSON Repair.
Preserve key order for diffs
JavaScript preserves insertion order, but two parsers shouldn’t be assumed equal. Use Sort JSON Keys before diffing or hashing.
Big integers lose precision
JS numbers lose precision past 2^53−1. Transport large IDs as strings or use BigInt.
Escape inside HTML
When inlining JSON inside <script>, escape </ to <\/ so HTML parsing doesn’t close your tag early.
Validate at boundaries
Trust the wire as little as possible. Run incoming JSON through a schema (Zod / Pydantic) before it touches business logic.
Minify in production
Minify removes whitespace; gzip removes redundancy. Together they typically shrink JSON payloads 70–85% over the wire.
When to flatten JSON
Anywhere downstream tooling expects flat key-value pairs.
Spreadsheet export
Flatten before piping to JSON to CSV for one column per leaf. Output round-trips losslessly through JSON.parse + JSON.stringify, so the file you save is byte-identical to what you see. Streaming parsers, jq pipelines, and Postgres jsonb columns all accept the result without complaint.
10× faster to scanFeature flag stores
LaunchDarkly, ConfigCat, Flagsmith expect flat paths. Pairs perfectly with sort-keys + diff for review-friendly fixtures in CI. Whitespace-only churn disappears and reviewers see real changes, which keeps PR comments focused on logic rather than indentation.
cleaner PR diffsenv vars
Some env-var systems use APP_DB_HOST with underscores — flatten with _ as separator.
Analytics
Some analytics platforms expect flat event payloads. Re-parses on every keystroke so syntax errors are caught at the exact character. Strict RFC 8259 — no trailing commas, no comments, no unquoted keys — keeps downstream parsers happy.
round-trip safei18n keys
Flatten translations to dot-keyed strings for translator workflows. Streams large documents without a server round-trip — privacy stays in the tab. Heavy parsing runs through useMemo so even 5 MB payloads keep the editor responsive.
i18n-friendlyReverse: unflatten
Take a flat property file and rebuild nested config. Output is byte-stable: same input plus same options always produces identical bytes, ideal for content-addressed caches and snapshot tests. Downloads ship with the application/json MIME so editors apply syntax highlighting.
production-readyFrequently asked questions
Something missing?
Tell us what you need. We ship the top requests every two weeks.