JSON Flatten
Collapse nested JSON into a single object keyed by dot and bracket paths.
Conversion payloads stay in this browser tab and are never placed in page URLs - see how local processing works. Privacy-safe analytics record only the tool, outcome, and a coarse input-size bucket. Press Cmd/Ctrl + Enter to convert.
How to Flatten JSON
Paste any JSON document and every leaf value is emitted with the full path needed to reach it. The result is a single-level object you can paste into a spreadsheet, turn into environment variables, or diff line by line - flat paths make a diff readable in a way that nested JSON never is.
Path Examples
How each shape is addressed.
| Input | Output | Note |
|---|---|---|
| {"a":{"b":1}} | {"a.b": 1} | Nested object |
| {"a":[1,2]} | {"a[0]":1,"a[1]":2} | Array index |
| {"a b":1} | {"[\"a b\"]": 1} | Key needs brackets |
| {"a":{}} | {"a": {}} | Empty kept as leaf |
Frequently Asked Questions
What path syntax is used?
Dot notation for identifier-safe object keys (user.address.city), bracket notation for array indexes (roles[0]), and quoted brackets for keys containing spaces, dots, or other characters that dot notation cannot express (headers["content-type"]).
Is flattening reversible?
Yes. Empty objects and empty arrays are kept as leaf values rather than dropped, so the JSON Unflatten tool can rebuild the original structure exactly. Round-tripping a document through both tools returns what you started with.
Why flatten JSON?
To get nested data into formats that have no concept of nesting: CSV columns, environment variables, i18n translation files, form field names, feature-flag keys, and log fields that must be indexed as flat pairs.
How are arrays of objects handled?
Each element gets its index in the path and its own keys continue from there, so items[0].name and items[1].name become separate entries. Nothing is merged or summarized.