AZ Tools

JSON Flatten / Unflatten (Dot Notation)

Developer

Paste JSON and switch between two modes. Flatten collapses a nested object or array into one flat object whose keys are paths like `app.server.ports[0]` — handy for environment variables, MongoDB update paths, i18n message files, CSV columns, or diffing two configs. Unflatten does the reverse, expanding flat dot-notation keys back into a nested structure. Choose the delimiter (`.`, `/`, `_`, `-`) and whether arrays use bracket notation (`items[0]`) or dotted indices (`items.0`). Empty objects and arrays are preserved as leaves so a flatten → unflatten round-trip returns exactly what you put in. Everything runs locally — your JSON never leaves the browser.

Arrays:

Output · 9 keys

{
  "app.name": "demo",
  "app.version": "1.2.0",
  "app.features[0]": "search",
  "app.features[1]": "export",
  "app.server.host": "localhost",
  "app.server.ports[0]": 8080,
  "app.server.ports[1]": 8081,
  "flags.beta": true,
  "flags.maxUsers": 100
}

Flatten and unflatten are exact inverses unless an object key contains the delimiter — switch delimiters if your keys have dots.

How to use

  1. Pick Flatten or Unflatten.
  2. Paste your JSON into the input box.
  3. Set the delimiter and array notation to match your target format, then copy the result.

Frequently asked questions

Is the conversion reversible?
Yes, for normal data. Flattening then unflattening with the same delimiter and array notation returns an identical object — empty objects/arrays and null values are kept as leaves so nothing is lost. The one exception is below.
What if an object key contains the delimiter?
Then the round-trip is ambiguous: a key like `a.b` flattened with the `.` delimiter is indistinguishable from nested `a` → `b`, so unflatten will split it. If your keys contain dots, pick a different delimiter (e.g. `/`) that doesn't appear in them.
How are array indices handled?
In bracket mode arrays become `list[0]`, `list[1]`; in dot mode they become `list.0`, `list.1`. On unflatten, any bracket index or a bare numeric segment is rebuilt as an array element, so a flat key `users.0.name` produces an array of objects.
Does it modify my data types?
No. Numbers, booleans, null, and strings are preserved exactly as JSON values; only the key structure changes. Output indentation (0/2/4 spaces) only affects formatting, not content.

Related tools