CoreJSON

JSON Flatten

This tool flattens nested JSON into a single-level object whose keys are paths, such as user.name, user.tags[0] and server.port — handy for writing config, doing diffs, or feeding data systems that only accept flat key-value pairs. The path delimiter and array notation are configurable, and flattening runs locally in your browser so nothing is uploaded.

Open in the workbench Runs locally · nothing is uploaded

How to use it

  1. 1

    Paste nested JSON

    Put a multi-level object into the input, or open a local .json file.

  2. 2

    Choose delimiter and array style

    The key delimiter defaults to a dot (.) and can be changed to _, / or -. Array index notation can be bracket (tags[0]) or index (tags.0).

  3. 3

    Adjust the output

    Pick an indentation and decide whether to recursively sort keys; each flatten run reports the number of leaf fields.

  4. 4

    Copy or invert

    Copy the flat result, or click "Invert with output" to restore it straight back to a nested structure.

Key features

Path keys

Nesting levels are joined automatically into keys like a.b[0].c, so the structure is easy to read at a glance.

Selectable array notation

Use bracket (tags[0]) or index (tags.0) style to match the conventions of different tools.

Empty containers preserved

Empty objects and arrays are kept as leaves so they are not silently lost during flattening.

Scalar key escaping

Keys that already contain the delimiter are handled consistently so the resulting paths stay unambiguous.

Worker-based local compute

Large objects are flattened on a background thread so the interface stays smooth and the data is not uploaded.

Field count in the status bar

Each run reports how many leaf fields were produced so you can confirm no level was dropped.

Common errors & troubleshooting

  • ! If an original key already contains the delimiter (for example a.b), it can collide with a path after flattening — normalise names first or pick an unusual delimiter.
  • ! The status bar shows the field count after flattening so you can check it against expectations and catch missing levels.
  • ! Choose an array notation that matches the tools you will feed the data into, to avoid re-converting later.
  • ! Empty objects and arrays are kept as leaves, so a flat output with a {} or [] value means the nested structure had an empty container.

Frequently asked questions

Can I switch between flatten and unflatten?

Yes. They are inverses of each other, and the "Invert with output" button on the same page restores the flat result back into a nested structure.

How are arrays handled?

Arrays are expanded by index into keys such as key[0], key[1] and so on; an empty array is kept as a leaf.

Is my data uploaded?

No. Flattening happens locally in your browser.

What delimiter should I use?

The dot is the most common and matches environment-variable style paths, but you can switch to _, / or - when a key already contains dots.

Related tools