JSON Flatten / Unflatten

Convert nested JSON to dot-notation keys and back, losslessly.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

JSON Flatten / Unflatten converts deeply nested JSON into flat dot-notation keys and turns flat path keys back into nested objects and arrays. It is built for developers who need to move data between structured JSON and the many systems that expect a single level of keys: spreadsheets and CSV exports, environment-variable stores, feature-flag platforms, i18n translation files, form libraries, and config formats that index everything by path. Instead of hand-writing recursive traversal code every time, you paste your JSON, pick a direction, and get a clean, copyable result.

The two directions are exact inverses. Flattening walks every branch of your object and emits one key per leaf value, where the key is the full path to that value — user.address.city, roles[0], settings.notifications.email. Unflattening reads those path keys and rebuilds the original tree, deciding at each step whether to create an object or an array based on whether the next segment is a numeric index. Because both directions share the same delimiter and array-style options, you can flatten data, edit or diff it as a simple key/value list, then unflatten it back into the shape your application expects.

How it works

When flattening, the tool recursively descends your parsed JSON. Primitive values (strings, numbers, booleans, null) become leaves keyed by their full path. Object keys are joined with your chosen delimiter; array items are joined either as bracket indices like items[0] or with the delimiter like items.0, depending on the array-mode setting. Empty objects and empty arrays have no leaf inside them, so you can either keep them as explicit {} / [] leaf values (the default, which preserves them across a round-trip) or drop them entirely.

When unflattening, each flat key is tokenised into ordered segments. Bracket groups are split out first, then the remaining text is split on the delimiter. A segment is treated as an array index when it sits inside brackets, or — in delimiter array-mode — when it is all digits. The tool then walks those segments, creating arrays and objects on demand, and finally assigns the leaf value. The whole thing is pure client-side JavaScript: no network calls, no uploads.

Example

Start with a nested object and flatten it:

{ "user": { "name": "Ada", "roles": ["admin", "editor"] } }

becomes

{ "user.name": "Ada", "user.roles[0]": "admin", "user.roles[1]": "editor" }

Now switch to Flat to Nested, paste that flat object back in, and you recover the original structure exactly. Use the Round-trip button to do this in one click — it moves the current output into the input and flips the direction automatically, which makes it easy to verify that your data survives the conversion both ways.

DirectionInputOutput
Flatten{"a":{"b":1}}{"a.b":1}
Flatten (array){"x":[10,20]}{"x[0]":10,"x[1]":20}
Unflatten{"a.b.c":true}{"a":{"b":{"c":true}}}
Unflatten (array){"x[0]":10,"x[1]":20}{"x":[10,20]}

Every conversion happens in your browser — nothing is uploaded or stored on a server.

Ad placeholder (rectangle)