>_devtools

JSON Flatten

Flatten nested JSON into single-level dot or bracket paths with a custom separator and depth limit.

What this does

Collapses nested JSON into a single object whose keys are paths to each value, such as user.address.city or user.emails[0]. Flat key/value data is easier to diff, search, load into a spreadsheet, or map to environment variables and form fields.

Options

  • Separator: any text such as ., /, _, or ::.
  • Arrays: bracket style (items[0]) or dot style (items.0).
  • Max depth: flatten only the first n levels and keep deeper values as nested JSON. 0 flattens everything.

Edge cases

Empty objects and arrays are kept as values so no information is lost. A key that contains the separator, brackets, or only digits, or is empty, is written in quoted bracket form such as ["a.b"], so the result can always be turned back into the original with Unflatten.

The top level must be an object or an array.

Example

Input:

{"user":{"name":"Ada","emails":["a@x.io","b@x.io"]},"active":true}

Result:

{
  "user.name": "Ada",
  "user.emails[0]": "a@x.io",
  "user.emails[1]": "b@x.io",
  "active": true
}

Privacy

Everything runs in your browser. Your input is never uploaded, stored, or put in the page URL.