JSON Unflattener

Rebuild nested JSON from flat dot-path keys — privately in your browser.

Free online JSON unflattener. Expand a flat object of dot-path keys back into nested JSON objects and arrays. Privacy-first: your JSON never leaves your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

How does it decide between an object and an array?

When the next path segment is a number — either a delimiter-separated index like roles.0 or a bracket index like roles[0] — that level is built as an array. Otherwise it is built as an object, and numeric-keyed objects are normalised into real arrays.

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.0 or a bracket index like roles[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.

When to use this tool

The most common situation is receiving data from a flat-only system — Redis hashes, certain CSV exports, or Elasticsearch source documents that have been serialised with dot-notation keys — and needing to restore the original shape before passing it to a library that expects proper nesting.

It is also useful when debugging configuration files. Many systems flatten their config when writing it to a KV store and you want to inspect what the original YAML or JSON looked like. Paste the flat snapshot in, click Unflatten, and the structure is immediately readable.

A third use case is round-tripping through the companion JSON Flattener. Flatten a complex object to compare two versions key-by-key, diff them, then unflatten the result back into a nested structure for further processing.

Practical guidance

Delimiter mismatch is the most common problem. If your source used underscores (user_name) rather than dots, change the delimiter field to _ before clicking Unflatten. Mixing delimiters in the same key set will produce unexpected top-level keys.

Ambiguous numeric keys can arise if you intentionally have an object with numeric string keys — for example {"0": "zero", "1": "one"}. After unflattening, those become a JSON array ["zero", "one"], which may not be what you want. Flatten and unflatten preserve the intent for standard data, but watch for this edge case with deliberately numeric-keyed objects.

Deeply nested paths like a.b.c.d.e work fine; the tool creates intermediate objects at each level automatically. If a path segment is missing in one key but present in another — say address appears as both a leaf ("address": "123 Main") and as a parent ("address.city": "Topeka") — the tool will overwrite the leaf with the object. Avoid mixing leaf and parent assignments at the same path.

Custom delimiters beyond a dot are supported. Common alternatives are /, >, __, and :. Enter whatever character your source system used.

Understanding the output

The rebuilt JSON is formatted with indentation so you can immediately see the depth and structure. Arrays appear as [...] and objects as {...}. After verifying the shape is correct, copy it to your clipboard with the Copy button and paste it into your editor, API client, or code.