About this tool
Flat keys are easier to use in spreadsheets, environment variables, translation files and search indexes. Flatten turns nested JSON into one level of keys such as user.address.city. Unflatten rebuilds the nesting, including arrays from numeric keys, and reports conflicting keys instead of silently overwriting them.
How to use it
- Choose Flatten or Unflatten.
- Set the separator, and whether array items use index keys.
- Paste JSON, then copy or download the result.
Example
{"user":{"name":"Riya","address":{"city":"Kolkata"},"tags":["admin"]}}{
"user.name": "Riya",
"user.address.city": "Kolkata",
"user.tags.0": "admin"
}Questions
- Can I always get the original back?
- Yes, unless a key already contains the separator, such as a key named "a.b". You'll get a warning when that happens, so you can pick a different separator.
- What happens to arrays?
- With "Arrays as indexes" on, items become keys like tags.0 and tags.1, and unflattening turns them back into arrays. Turn it off to keep arrays whole as values.
- What if two keys conflict when unflattening?
- Keys like "a": 1 and "a.b": 2 can't both exist, because a can't be a number and an object at once. The tool stops and names the conflicting key.