b2KIT

JSON Flatten / Unflatten Tool

Flatten nested JSON to dot-notation key-value pairs and unflatten back to nested structure.

Tested tool guide Tested browser tools Checked August 16, 2026

What JSON Flatten / Unflatten Tool does, with a checked example

JSON Flatten / Unflatten Tool switches between a nested JSON object and a flat JSON object whose keys encode nesting with periods. In flatten mode, an inner property becomes a key such as "person.name"; in unflatten mode, that path becomes nested properties again. This helps expose deep fields while retaining their path context. The common surprise is that dot notation is a convention outside JSON itself. A literal period inside an original property name can therefore be confused with a nesting separator.

Worked example

A concrete input and expected output from the current implementation.

Input

{
  "user": {
    "name": "Ada",
    "role": "admin"
  }
}

Expected output

{
  "user.name": "Ada",
  "user.role": "admin"
}

Both values are inside the original "user" object. Flattening joins that parent name to each child property with a period, producing two top-level path keys while preserving the associated string values.

How the result is produced

1

Flatten nested properties

Flattening replaces each chain of object property names with one period-separated key. Only the structural location is encoded in that key; the leaf value remains associated with the resulting path. In the example, "user.name" identifies the name property inside user, while "user.role" identifies its sibling. A top-level leaf already has no ancestor name to prepend.

2

Rebuild the property tree

Unflattening reads each period-separated key as a sequence of nested property names and places its value at that destination. For example, keys named "account.name" and "account.enabled" describe one account object containing two properties. The paths must form a consistent tree. A key that is both a completed value and the prefix of another path creates a structural conflict.

Good uses

  • Turn a deeply nested API response sample into a compact path-to-value inventory when checking which exact field contains an identifier, status, or configuration value.
  • Prepare object fields for a worksheet or mapping system that expects one column-like name per leaf while keeping the original nesting visible in each dotted key.
  • Convert dot-named form or configuration entries back into a nested JSON object before comparing the result with the payload shape expected by another system.

Limits and checks

  • A property name that already contains a period is indistinguishable from multiple path segments unless a separate escaping convention is defined. JSON itself provides no such dot-path escaping rule.
  • Paths such as "a" and "a.b" cannot both describe an ordinary property tree where a is simultaneously a scalar leaf and an object containing property b.
  • Dot notation does not standardize how array indexes, empty objects, or empty arrays are represented. Verify those cases before relying on a round trip for mixed object-and-array data.

Common questions

Is the flattened result still valid JSON?

Yes, when the result is a JSON object. The dotted paths are ordinary JSON member names, and their associated data are ordinary JSON values. The periods have no special meaning to a JSON parser; they gain path meaning when this tool interprets the object during unflattening. Unquoted key-value lines, by contrast, would not themselves constitute valid JSON.

Will flattening and then unflattening always reproduce the original?

No. A straightforward object with unique property names and no periods in those names can map cleanly, as the example does. Exact round trips become ambiguous when names contain periods, when one flattened key is a prefix of another, or when arrays and empty containers need representation. Whitespace and property ordering are presentation details and should not be used to judge semantic equality.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools