JSON Flatten / Unflatten
Flatten nested JSON into dot-notation keys, or unflatten it back, instantly in your browser. Your data stays on your device.
Your JSON is flattened and unflattened locally in your browser and never uploaded, but avoid pasting secrets you would not want in your clipboard history.
Need to pretty-print first? Try the JSON Formatter.
About JSON Flatten / Unflatten
This JSON flatten tool collapses a nested JSON object into a single-level map whose keys are dot-notation paths, so {"a":{"b":1},"arr":[10,20]} becomes {"a.b":1,"arr.0":10,"arr.1":20}. Switch to unflatten and it rebuilds the original nested structure from those flat paths. Flat key/value shapes are easy to diff, store in .env or config files, map to spreadsheet columns, or feed into form libraries that key by path. You can change the delimiter from the default dot to anything you like, and choose whether array indices read as arr.0 or bracket-style arr[0]. Object keys, arrays, primitives, null, and empty containers are all handled, and the round trip is lossless. Everything runs entirely in your browser, so the JSON you paste is processed locally and never leaves your device.
Features
- Flatten nested objects and arrays into single-level dot-notation keys
- Unflatten flat path/value pairs back into the original nested JSON
- Choose any key delimiter — the default is a dot (.)
- Pick dot indices (arr.0) or bracket indices (arr[0]) for arrays
- Lossless round trip: flatten then unflatten returns identical JSON
- Handles primitives, null, and empty objects and arrays as leaf values
- Live two-pane view with parse errors surfaced inline as you type
- Copy the result or download it as flat.json or nested.json
How to use the JSON Flatten / Unflatten
- Pick Flatten or Unflatten with the mode toggle.
- Paste your JSON into the input panel on the left.
- Set the delimiter and, for flatten, the array key style if you want non-defaults.
- Read the converted JSON on the right, then Copy or download it.
Example
Input
{
"user": { "name": "Ada", "roles": ["admin", "dev"] },
"active": true
}
Output
{
"user.name": "Ada",
"user.roles.0": "admin",
"user.roles.1": "dev",
"active": true
}
Nested objects and array items become dot-notation keys ending in their index.
Common errors & troubleshooting
- Unflatten reports it expects a flat JSON object of path/value pairs. — Unflatten needs a single-level object like {"a.b":1}; switch to Flatten if you are starting from nested JSON instead.
- Unflatten produces an object with keys "0", "1" where you expected an array. — Array indices must be plain integer segments. If your delimiter differs from the keys, set the same delimiter so 0 and 1 are read as indices.
- Flattening loses values when two keys collide, e.g. a literal dot inside a key name. — Choose a delimiter that does not appear inside your keys (such as / or __) so each path stays unambiguous.
- The input shows a JSON parse error and no output appears. — Fix the highlighted syntax — JSON needs double-quoted keys and strings and no trailing commas. Try Load example for a valid starting point.
Frequently asked questions
- How are arrays flattened?
- Each array item becomes its own key ending in the item's index, so arr[10, 20] flattens to {"arr.0":10,"arr.1":20}. You can switch to bracket style to get arr[0] and arr[1] instead, and unflatten reads either form back into a real array.
- Can I change the key delimiter?
- Yes. The delimiter defaults to a dot, but you can set it to any character or short string — for example / or __. Use the same delimiter when you unflatten so the paths split back correctly.
- Is flatten then unflatten lossless?
- For well-formed JSON the round trip returns identical data: objects, arrays, strings, numbers, booleans, null, and empty containers are all preserved. The one thing to avoid is a delimiter that also appears literally inside a key name.
- What is the difference between dot and bracket array keys?
- It is purely how indices are written: dot style gives arr.0 while bracket style gives arr[0]. Both describe the same array position, and the unflatten step understands either notation, so pick whichever your other tools expect.
- Why would I flatten JSON?
- Flat path/value maps are easier to diff line by line, store in environment or config files, line up as spreadsheet columns, and bind to form fields that are keyed by path. Unflattening lets you turn that flat shape back into nested JSON when you need it.
- Does my JSON get uploaded anywhere?
- No. Flattening and unflattening run entirely in your browser, so the JSON you paste is processed locally on your device and is never sent to a server.
Related tools
- JSON Formatter — Beautify, minify and validate JSON with error locations.
- JSON Viewer — Text + collapsible tree viewer with expand/collapse and node paths.
- JSON to CSV — Convert an array of flat JSON objects to CSV.
- JSON Escape / Unescape — Escape text into a JSON string or unescape a JSON string back to raw text.
- JSON Diff — Compare two JSON documents and see a structural, key-order-independent diff.
- YAML ↔ JSON — Convert YAML to JSON and back.
All ArrayKit tools