Flatten JSON

Flatten JSON Online

Turn nested objects and arrays into dot-notation key-value pairs. Paste JSON, flatten it, and copy the result here for free.

Free on this page · No sign-up · Processed in your browser

Flatten JSON
Open flat JSON in editor
Nested JSON
Flattened JSON
Flattened 8 values — processed in your browser

Runs entirely in your browser — nothing is uploaded.

A JSON flattener replaces nested objects with one object whose keys contain the path to each value: user.address.city for an object field, or orders[0].total for an array item. This tool preserves JSON value types and empty containers. Flattening on this page runs in your browser, without an account, credits, or an upload.

Nested JSON, flattened

Input — nested
{
  "user": {
    "id": 42,
    "name": "Ada Lovelace",
    "address": { "city": "London", "zip": "EC1A" }
  },
  "orders": [
    { "id": "ord_1", "total": 29 },
    { "id": "ord_2", "total": 18.5 }
  ]
}
Output — flat dot notation
{
  "user.id": 42,
  "user.name": "Ada Lovelace",
  "user.address.city": "London",
  "user.address.zip": "EC1A",
  "orders[0].id": "ord_1",
  "orders[0].total": 29,
  "orders[1].id": "ord_2",
  "orders[1].total": 18.5
}

Every leaf value becomes one key holding its full path. Objects join with a dot, array elements carry a bracketed index, and both documents hold the exact same values — only the shape changes.

How to flatten JSON

  1. 1

    Paste nested JSON

    Replace the sample in the Nested JSON panel with your object or array.

  2. 2

    Select Flatten

    The result appears alongside your input. Invalid JSON produces an error; fix the input and run it again.

  3. 3

    Copy the flattened JSON

    Select Copy result, or open the flat JSON in the full editor for formatting and inspection.

What the flattener preserves

Object paths

Nested fields become keys such as user.address.city.

Array positions

Zero-based indexes remain in paths such as orders[0].total and matrix[1][0].

Value types

Numbers, strings, booleans, and null keep their JSON types.

Empty containers

Empty objects and arrays remain in the result as {} and [].

Empty values, root arrays, and unusual keys

For {"items": [], "settings": {}, "deleted": null}, the output retains all three keys and their values. A root array uses paths such as [0].id. A root primitive, such as 42 or null, is stored under the empty key "" because it has no parent path.

Literal dots or brackets in your original keys can make paths ambiguous. For example, {"a.b": 1, "a": {"b": 2}} produces the same path twice. This tool reports the collision rather than overwriting a value. Rename conflicting keys before flattening and keep the original file if you need to reconstruct it.

Flattening, minifying, and CSV are different operations

Minifying removes whitespace while keeping the nested document intact. Flattening changes the shape of the data by moving its nesting into key names. Neither operation converts the result into a spreadsheet file.

To export records as columns and rows, use JSON to CSV or JSON to Excel. Their array-of-records workflow is more suitable than copying a flat JSON object directly into a spreadsheet. CSV also loses JSON type distinctions, such as the difference between 42 and "42".

Frequently asked questions

Is this JSON flattener free?

Yes. Flattening on this page is free, runs in your browser, and needs no account or credits. The separate Copilot action in the editor uses the account credit system.

Does flattening upload my JSON?

No. The tool on this page processes your input locally. Opening the editor is a separate step; AI actions and cloud saving have their own data handling.

Does it flatten arrays?

Yes. Each element gets a zero-based bracketed index, such as items[0].sku. Nested arrays produce paths like matrix[0][1]. Empty arrays are preserved.

Can I unflatten the output?

There is no unflatten action on this page. Dot-and-bracket paths can be ambiguous when source keys contain those characters, so keep your original nested JSON for a reliable round trip.

Why does flattening fail?

The input must be valid JSON, and two values must not produce the same flattened path. Fix syntax errors or rename conflicting keys, then try again.

Related tools

Keep reading

Explore your JSON in the full editor

Open the Editor