Skip to content
UniKit

JSON Flattener

Flatten deeply nested JSON into single-level a.b.c keys, depth-first and in the original key order, with arrays kept as leaf values. Everything runs locally in your browser.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

JSON input

Nested plain objects become dotted flat keys; arrays and primitives stay as leaf values.

Flattened JSON

Depth-first traversal keeps the original key order and produces "a.b.c" style keys; values are untouched.

Paste JSON to see the flattened result

What this tool does

  • Flatten a deeply nested API response into single-level keys that import cleanly into Excel or a database
  • Compare the flat key sets of two config files to spot structural differences

Example

Input

{"user":{"name":"Ada","age":37},"tags":["a","b"]}

Output

{
  "user.name": "Ada",
  "user.age": 37,
  "tags": [
    "a",
    "b"
  ]
}

Only plain objects are expanded; arrays are kept as a single leaf value.

Frequently asked questions

Are objects inside arrays flattened?

No. Arrays (including arrays of objects) stay as leaf values, so [{...}] never yields keys like a.0.x.

Why did my empty object disappear?

Flattening collects leaf values by key path, and an empty object has no leaves, so {"a":{}} produces no key at all. A top-level primitive likewise yields {}.

What if a key name already contains a dot?

It collides with the path syntax. In {"a":{"b":1},"a.b":2} both sources map to the key a.b and the later one wins, leaving {"a.b":2}.

Can the result be expanded back?

Yes, with the JSON expand tool, which turns a.b.c keys back into nested objects. Structures whose original keys contained dots cannot be restored exactly.

Keywords:json flattenernested json to flat

Related tools