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

How to use the JSON Flatten / Unflatten

  1. Pick Flatten or Unflatten with the mode toggle.
  2. Paste your JSON into the input panel on the left.
  3. Set the delimiter and, for flatten, the array key style if you want non-defaults.
  4. 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

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

All ArrayKit tools