Flatten Nested JSON
Flattening rewrites nested structure as single dot-notation keys. Pretty-print your object in the tool below to see the nesting clearly, then apply the flattening rules explained here.
The dot-notation idea
Flattening joins the path to each leaf value with dots: {"user":{"address":{"city":"London"}}} becomes {"user.address.city":"London"}. The result is a single-level object where every key encodes its full path.
Handling arrays
Arrays flatten with an index in the key: {"tags":["a","b"]} becomes {"tags.0":"a", "tags.1":"b"}. Some tools use bracket notation like tags[0] instead — pick one convention and keep it.
Where it helps
Flat keys map neatly onto spreadsheet columns, environment variables, and feature-flag stores that only accept string keys. To reverse it, split each key on the dots and rebuild the nesting.
FAQ
Is flattening reversible?
Yes, if keys are unambiguous. Split each key on the delimiter and rebuild the nested objects and arrays from the path segments.
What if a key already contains a dot?
Then dot delimiters are ambiguous. Choose a delimiter your keys never use, or switch to bracket notation for array indices.
How are arrays represented?
Each element gets its index in the key, e.g. items.0, items.1 — or items[0], items[1] depending on the convention you pick.