JSON Flatten / Unflatten
Flatten nested JSON into a single level of dotted keys such as user.emails[0], or turn flat keys back into the nested structure, with your own delimiter.
Use the tool
Why this tool exists
Many tools cannot take nested data: spreadsheets, environment variable systems, translation files, form libraries and key-value stores all want one level of keys. Going from {"user":{"emails":["a"]}} to user.emails[0] is easy for a person and tedious for a hundred fields.
This tool flattens with a delimiter you choose, and writes array positions either in brackets or as extra segments. Unflatten rebuilds objects and arrays from those keys. Empty objects and arrays are kept as values rather than lost. Round trips work when your keys do not contain the delimiter itself, so pick a rare one such as a slash or a double underscore if your data has dots in its keys.
How to use it
- Paste your JSON and pick flatten or unflatten.
- Set the delimiter, and tick the option to write array indexes as [0].
- Copy the converted JSON.
Frequently asked questions
How are arrays flattened?
By default as brackets, user.emails[0]. Without the bracket option they become dotted numbers, user.emails.0. The same setting decides how unflatten reads them back.
What if a key contains the delimiter?
Then flattening is ambiguous and unflatten may split it wrongly. Choose a different delimiter such as a slash before converting data like that.
What happens to empty objects and arrays?
They are kept as the value of their key, so a field holding an empty object stays visible. Nothing is silently dropped during flattening.
Does unflatten need an object?
Yes. The input must be a JSON object whose keys are the flat paths. Arrays or plain values at the top level produce an error.