Flatten JSON
About this tool
About JSON Flatten
Flattening turns nested JSON into a single-level object whose keys are paths: {"user":{"address":{"city":"London"}}} becomes {"user.address.city":"London"}. That shape is what spreadsheets, CSV exports, search indexes, translation files, environment variables and many analytics tools expect. This tool flattens objects and arrays of any depth. Choose the separator (a dot, underscore, slash or anything else) and how array positions appear: as plain segments like tags.0 or in brackets like tags[0]. Empty objects and arrays are kept as {} and [] so nothing is lost. Switch the mode to Unflatten to rebuild the nested structure from path keys: numeric segments become array positions again, and Use as input lets you round-trip in one click. It also works on a top-level array of records. Output can be pretty or on one line. Processing runs entirely in your browser, so your data stays on your device.
Built and maintained by Abhi JainUpdated
How to Flatten JSON
- 1
Paste nested JSON
Paste JSON into the Nested JSON pane or open a file. Click Sample to try an example.
- 2
Pick the key style
Set the Separator and choose how Array keys look, tags.0 or tags[0].
- 3
Copy the flat JSON
Copy or download the result. Switch Mode to Unflatten to convert flat keys back into nested JSON.
JSON Flatten: questions and answers
What does flattening JSON mean?
It replaces nested objects and arrays with one level of keys, where each key is the path to a value. {"a":{"b":[1,2]}} becomes {"a.b.0":1,"a.b.1":2}.
How are arrays flattened?
Each item gets its position as a path segment: tags.0 and tags.1 with the dot style, or tags[0] and tags[1] with the bracket style.
Can I convert flat JSON back to nested JSON?
Yes. Switch Mode to Unflatten or use JSON Unflatten. Numeric segments become array positions, so the original structure is rebuilt.
What if my keys already contain dots?
Choose a separator that doesn't appear in your keys, such as / or __, so the paths can be split back correctly.
Is my JSON uploaded?
No. It is processed in your browser.
Ready-made JSON Flatten presets
Related Tools
- JSON to CSVConvert a JSON array to CSV, flattening nested objects and choosing the columns you want.
- JSON FormatterBeautify, minify and validate JSON with exact error locations, without changing a single value.
- JSON ViewerExplore JSON as a collapsible tree with search and one-click path copying.
- JSON Sort KeysSort the keys of every JSON object alphabetically, at every level.