JSON Flattener Online
Flatten nested JSON to dot-notation keys or unflatten back to nested objects.
When a JSON flattener is the right tool
Nested objects are awkward to scan in a spreadsheet or a log. This page is for turning one JSON value into a single object whose keys encode the path, or for attempting the reverse. Choose Flatten or Unflatten, paste the JSON, and the output updates as you type. In Flatten mode you can pick Dot or Bracket for array indexes.
Unflatten is not a perfect inverse: arrays come back as objects, and bracket keys are not parsed. If you only need a few fields, the JSONPath Tester may be enough.
Use cases
Making a nested payload easier to scan
Load Sample pastes a user object with a nested address and a tags array. Flatten with Dot to get keys such as user.address.city and user.tags.0. That map is easier to grep or to paste into a table.
Using bracket indexes for arrays
Bracket mode writes user.tags[0] instead of user.tags.0. Object names still use dots. This style is handy to read, but Unflatten will treat tags[0] as a literal key, so switch back to Dot first if you plan to go the other way.
Rebuilding a nested object from dotted keys
Paste a flat object and choose Unflatten. Paths split on every dot become nested objects. Review array-like keys carefully; they will not be arrays in the result.
How flattening works
The input is parsed as JSON. Flatten walks objects and arrays until it reaches a leaf (a non-object, including null) and writes that value under a path key. Unflatten splits each key on . and assigns the value into a tree of objects. The output is pretty-printed with 2-space indent. Empty input leaves the output empty.
{
"user": {
"name": "Alice",
"tags": ["admin", "user"]
}
}
{
"user.name": "Alice",
"user.tags.0": "admin",
"user.tags.1": "user"
}The array indexes are 0 and 1 after a dot. In Bracket mode those two keys would be user.tags[0] and user.tags[1].
{
"user.name": "Alice",
"user.tags.0": "admin",
"user.tags.1": "user"
}
{
"user": {
"name": "Alice",
"tags": {
"0": "admin",
"1": "user"
}
}
}tags comes back as an object with string keys "0" and "1". That is expected on this page, not a pretty-print artifact.
What this tool does not do
It does not restore arrays, parse bracket indexes on the way back, or keep empty objects and empty arrays as leaves. Nothing is sent to a server. To tidy the JSON first, use the JSON Formatter.
How to use JSON Flattener
- Choose Flatten or Unflatten. In Flatten mode, pick Dot or Bracket for array indexes.
- Paste JSON, or use Load Sample for a short nested user object.
- Copy the result when it looks right, or Clear to start over.
Frequently asked questions
What is the difference between the Dot and Bracket separators?
The separator is used only in Flatten mode, and it only changes how array indexes are written. Dot produces keys such as user.tags.0. Bracket produces user.tags[0]. Object keys always use a dot, even in Bracket mode, so you will still see user.name and user.address.city.
Does Unflatten restore arrays?
No. Unflatten always splits keys on dots and builds nested objects. Numeric segments such as 0 become object keys, not array indexes, so a flattened tags.0 / tags.1 pair comes back as an object { "0": …, "1": … }. Bracket keys such as user.tags[0] are not parsed: after the split you get a literal property named tags[0] on user. Switch the separator back to Dot if you plan to unflatten.
What happens to empty objects, empty arrays, or a JSON array at the root?
Empty objects and empty arrays do not appear in the flattened output, because there are no leaf values to write. null and numbers are kept. A root array in Dot mode uses keys 0, 1, 1.x, and so on; in Bracket mode the keys look like [0] and [1].x.
Is flattening live as I type?
Yes, after the input parses as JSON. Switching Flatten and Unflatten does not clear the input, so you can flatten and then unflatten the same text (or paste a flat object and switch to Unflatten). Invalid JSON shows “Invalid JSON” and leaves the output empty.
Is my JSON sent to a server?
No. Flattening and unflattening run in your browser as you type. Closing the tab discards what you pasted. Do not paste documents that contain secrets if you would not be comfortable with them sitting in memory on this device.
Is there a file size limit?
There is no server-imposed limit, because nothing is uploaded. Typical API payloads are comfortable. A very large or deeply nested document can make the tab feel slow; in that case, flatten a smaller excerpt.
Related tools and guides
References
- There is no single standard for flattening JSON. Many libraries offer dotted keys, bracket indexes, or both, and they differ on whether arrays are restored. This page uses the rules described above.
- If you need a lossless round trip, including real arrays, flatten and rebuild the structure in a script rather than relying on Unflatten here.