Developer Tools Runs in your browser Free · no account

JSON Unflatten

The JSON unflattener takes a single-level object whose keys are dot-separated paths and rebuilds the nested structure they describe. Numeric path segments become array indexes, so user.roles.0 is restored as an array rather than an object with a "0" key.

Options
Flat JSON 0 characters
Nested JSON

Your result will appear here.

Not sure where to start? Use Load example.

Results update automatically and are calculated on your device. Nothing you type is sent to a server.

Runs in your browser. Processing happens entirely in your browser. Nothing you enter is sent to Delimiter.live.

How to use the JSON Unflatten

  1. Paste the flat JSON object whose keys are paths.
  2. Set the separator to match the one used in those keys.
  3. Read the rebuilt nested document.
  4. Copy or download the result.

Example

Input
{"user.city": "London"}
Output
{
  "user": {
    "city": "London"
  }
}

Common use cases

  • Turning flat environment configuration back into a structured config file.
  • Rebuilding nested records from a spreadsheet export with dotted column headers.
  • Reversing a flatten step in a data pipeline.
  • Converting a flat key-value store dump into a readable nested document.

Limitations and things to watch for

  • The input must be a flat JSON object. A nested document, or a top-level array, is rejected rather than partially processed.
  • Keys that contained the separator before flattening cannot be distinguished from real path boundaries, so those documents will not round-trip.
  • A path where one segment is used as both an object and a value — such as a and a.b together — resolves in favour of the deeper path, because one of the two has to win.

Frequently asked questions

How does it know when to build an array?
A path segment made entirely of digits is treated as an array index, so roles.0 and roles.1 rebuild an array. An object is created for any non-numeric segment.
What if a path index is missing?
Gaps produce null entries in the resulting array, because JSON arrays cannot have holes. If you rebuild from roles.0 and roles.2 you will get three elements, with the middle one null.
Does this reverse the JSON Flatten tool exactly?
Yes, as long as none of the original keys contained the separator character and you use the same separator in both directions.
Why is my top-level array rejected?
Unflattening needs an object whose keys are paths. A top-level array has no keys to interpret, so there is nothing to rebuild from.

Share this tool