JSON

JSON Path Extractor / Flatten

Flatten nested JSON into a flat "path: value" list, and rebuild it back into a nested structure (Unflatten). Path notation matches JSONPath/JSON Diff: store.book[0].price.

Deeply nested JSON is hard to compare or iterate over programmatically. Flatten unrolls such a structure into a flat list of "path: value" pairs (e.g. store.book[0].price: 12.99), and Unflatten rebuilds it.

How to use it

Common uses

Things to keep in mind

Array index notation varies between libraries — this tool uses items[0], though some write items.0 without brackets.

Unflatten requires that paths don't conflict with each other (e.g. one and one.two at the same time) — otherwise the structure can't be unambiguously rebuilt.

Article about this tool: JSON Flatten: turning a nested structure into a flat list

Frequently asked questions

Why would I flatten a JSON document?

A flat "path: value" list is handy for exporting to a spreadsheet, comparing values, or finding a specific field in a large nested document without scrolling through the structure.

How are array elements represented in the path?

Array elements get indexed keys in square brackets, like store.book[0].price — the same path notation used by the JSONPath and JSON Diff tools.

Does Unflatten always rebuild the exact original structure?

Yes, as long as the paths do not contradict each other. If two paths imply different value types at the same point (say, an object and a primitive), the tool reports a conflict instead of silently overwriting one.

What if a real key already contains a dot?

That is an inherently ambiguous case: the path user.name could mean either the nested object {"user": {"name": ...}} or the flat key {"user.name": ...}. Dotted notation cannot tell the two apart, so such keys are best avoided or handled separately.

Is the path format the same across every similar tool?

No. Dot notation for objects (user.name) is nearly universal, but array index notation varies — this tool uses items[0], while some libraries write items.0 without brackets.

Articles: JSON