JSON Flatten / Unflatten
Flatten nested JSON into single-level path keys like user.tags[0], or unflatten them back. Choose the delimiter and array style; round-trips without losing data.
Runs in your browser · Nothing uploaded · No sign-up
Something not working, or missing a feature? Send feedback
About the JSON Flatten / Unflatten
JSON Flatten turns a nested document into one flat object whose keys are paths, like user.roles[0], which is easier to diff, search, store in a spreadsheet or send as form fields. JSON Unflatten rebuilds the original nesting from those keys, so the two directions round-trip without losing data.
Everything runs in your browser, so your input is never uploaded to a server.
How to use the JSON Flatten / Unflatten
- Choose Flatten, or Unflatten to rebuild nested JSON from path keys.
- Paste the JSON and pick the delimiter and the array style (a[0] or a.0).
- Copy the result. Swap moves the output back into the input and flips the direction.
Examples
Input
{
"id": 7,
"user": { "name": "Ada", "roles": ["admin", "dev"] },
"orders": [{ "sku": "A1", "qty": 2 }],
"meta": {}
}Result
{
"id": 7,
"user.name": "Ada",
"user.roles[0]": "admin",
"user.roles[1]": "dev",
"orders[0].sku": "A1",
"orders[0].qty": 2,
"meta": {}
}Objects are joined with dots and array items get an index in brackets. The empty meta object is kept as a value.
Input
{
"user.name": "Ada",
"user.roles[0]": "admin",
"user.roles[1]": "dev",
"active": true
}Result
{
"user": {
"name": "Ada",
"roles": [
"admin",
"dev"
]
},
"active": true
}Keys such as user.roles[0] create the user object and the roles array again.
Common mistakes
- Keys that contain the delimiter. A key like "a.b" flattens to the same path as {"a": {"b": ...}}, so unflattening cannot tell them apart. Choose a delimiter that does not occur in your keys.
- Sparse array indexes. If you unflatten only a[0] and a[2], the missing slot is filled with null so the array keeps its positions.
- Expecting arrays to stay arrays. After flattening, an array is just numbered keys. Unflatten needs the same array style (a[0] or a.0) that was used to flatten.
Works well with the JSON Flatten / Unflatten
- JSONPath Tester: query the original document with a path.
- JSON to CSV: turn records into a table instead of path keys.
- JSON Formatter: sort the keys and adjust the layout.
Frequently asked questions
Can I use another separator than a dot?
Yes: slash, underscore or colon. Pick a character that does not appear in your keys, otherwise Unflatten cannot tell a key containing the delimiter from nesting.
What happens to empty objects and arrays?
With Keep {} and [] on, they stay as values, so unflattening restores them. Turn it off to drop them from the flat result.
Is the result the same as the usual flatten libraries?
For the common dot-and-bracket style, yes: arrays are shown as a[0], like the output of many flatten libraries. Choose a.0 for the style that treats array indexes as plain keys.
Why does unflatten reject a key like __proto__?
Building objects from untrusted keys can pollute the prototype of every object. The tool refuses those names, so pasting data from an untrusted source is safe.
Related tools
Case Converter
Convert text between camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, Title Case and more online. Rename variables and keys in one paste.
Remove Duplicate Lines
Remove duplicate lines from text online, keeping the first occurrence and the original order. Optionally ignore case, extra spaces and empty lines.
Sort Lines
Sort lines of text online alphabetically, naturally (item 2 before item 10), by number or by length, in ascending or descending order. Runs in your browser.
URL Parser
Parse a URL online into protocol, host, port, path, query parameters and fragment. Read long tracking links and debug query strings at a glance.
Cron Expression Parser
Explain any cron expression in plain English and see its next run times in your time zone. Validates crontab syntax, steps, ranges, names and @daily macros.
Word & Character Counter
Count words, characters, lines, sentences and bytes online, with estimated reading time. Check essays, posts and meta descriptions against length limits.