JSON Flatten and Unflatten Online
Flatten nested JSON into one level of keys like user.address.city, or unflatten dot-notation keys back into nested objects. Choose the separator and how arrays are written. Runs in your browser, so your data is never uploaded.
JSON Input
JSON Result
What Does Flattening JSON Mean?
Flattening turns nested JSON into a single level: every value gets one key that spells out its path, such as user.address.city. Flat data fits places that have no nesting: CSV and spreadsheet columns, database fields, environment variables, translation files and analytics events. Unflattening does the reverse and rebuilds the nested structure from those keys.
How to Flatten or Unflatten JSON
- Paste your JSON, drop a .json file on the box, or load it from a link with URL.
- Pick the separator and how arrays should be written.
- Click Flatten to get one level of keys, or Unflatten to rebuild nested JSON.
- Copy or download the result, or send it to another tool with Open in.
Example
{
"user": {
"name": "Emily",
"address": { "city": "London" }
},
"roles": ["admin", "editor"]
}{
"user.name": "Emily",
"user.address.city": "London",
"roles.0": "admin",
"roles.1": "editor"
}Options
| Option | Choices | Typical use |
|---|---|---|
| Separator | . _ __ / : | Dots for most tools, __ for environment variables (DB__HOST), / for path-like keys, : for .NET configuration |
| Arrays | roles.0, roles[0], or kept as lists | Brackets match JavaScript and lodash paths; keeping lists flattens objects only |
| Numbers make arrays | On or off (unflatten) | On: items.0 becomes a list. Off: "0" stays an object key |
Things to Know
- Empty objects and lists are kept as
{}and[], so flattening and unflattening give back exactly the same JSON. - Keys that already contain the separator, like
"file.name"with dot as separator, cannot be split back exactly. The tool counts them and suggests another separator. - Conflicting keys such as
"a": 1and"a.b": 2cannot both exist in nested JSON; unflattening names the keys that clash. - Gaps in lists, for example only
items.2, are filled withnullso the result is valid JSON.
Tips
- Going to a spreadsheet? JSON to CSV, JSON to TSV and JSON to Excel flatten nested objects into columns for you.
- Need to find values instead of flattening everything? Try the JSONPath Tester.
- Want the keys in order after flattening? Run the result through the JSON Sorter.
Frequently Asked Questions
How do I flatten nested JSON?
Paste the JSON and click Flatten. Every value gets one key that spells out its path, such as user.address.city, so the result has a single level. You can pick the separator and how arrays are written.
How do I unflatten dot-notation keys?
Paste a flat object such as {"user.name": "Emily"} and click Unflatten. The keys are split at the separator and rebuilt into nested objects; numeric parts like items.0 become arrays unless you turn that off.
Does flattening lose any data?
No. Empty objects and lists are kept, so flattening and unflattening return the same JSON. Only keys that already contain the separator cannot be split back exactly, and the tool tells you when that happens.
Is my JSON uploaded?
No. Flattening and unflattening run in your browser and your data never leaves your device.