JSON unflattener
Flat key/value data — from a .env file, a config store or a flattened export —
is hard to work with when your code expects nested objects. This tool expands a
flat JSON object whose keys are dot paths (like user.name or roles[0])
back into the original nested structure of objects and arrays.
How it works
The unflattener splits each key into path segments and rebuilds the structure level by level:
- A segment that is a number — either a delimiter index like
roles.0or a bracket index likeroles[0]— makes that level an array. - Any other segment makes that level an object.
- Objects that end up with only consecutive numeric keys are normalised into real arrays, so the result matches what the flattener started from.
Set the delimiter to match how the keys were built (a dot by default); bracket indices are detected automatically.
Example
This flat input:
{ "user.name": "Sam", "roles[0]": "admin", "roles[1]": "editor" }
unflattens to:
{
"user": { "name": "Sam" },
"roles": ["admin", "editor"]
}
The numeric roles indices rebuilt an array, and user.name rebuilt a nested
object. Output from the JSON flattener feeds straight back in — match the
delimiter and array style and you reconstruct the original. Everything runs in
your browser, so your JSON never leaves your device.