Skip to content

JSON Flatten

Flatten nested JSON into dot-notation keys.

Input
Output

No result

About JSON Flatten

Flattening collapses a nested JSON document into a single level, joining the keys along each path with dots — so {"a":{"b":{"c":1}}} becomes {"a.b.c": 1}. Every leaf value ends up with exactly one key that describes the full path to it.

The reason to do it is that a flat structure can go places a nested one cannot. Spreadsheet columns, CSV exports, database tables and log lines are all inherently flat, and flattening converts a nested API response into a row you can paste into any of them without losing the path information.

One behaviour is worth knowing in advance: arrays are not expanded. An array is carried through as a single value under its own key rather than being indexed into separate entries, which keeps list-shaped data intact instead of fragmenting it into numbered keys.

How to use JSON Flatten

  1. 1 Paste the nested JSON document.
  2. 2 Every path collapses into a dotted key, and the result appears immediately.
  3. 3 Copy the flat output for use as CSV columns, spreadsheet headers, or database field names.

Frequently asked questions

What happens to arrays inside my JSON?

They are kept whole. The flattening walks into nested objects but treats an array as a value, so it appears under its dotted path as a single entry rather than being split into indexed keys such as items.0 and items.1.

What if a key already contains a dot?

The result becomes ambiguous, since a dot in the output normally means "one level of nesting". If your data uses dots inside key names, note the original structure before flattening so you can interpret the result correctly.

Can I reverse the operation?

Yes — the JSON Unflatten tool expands dotted keys back into nested objects. The pair round-trips exactly provided no original key contained a dot of its own, which is the one case where the transformation is not reversible.

Why would I want flat JSON at all?

Mostly for destinations that cannot represent nesting. Spreadsheet columns, CSV headers and flat database tables all require a single identifier per value, and the dotted path preserves where the value came from inside the original structure.

Free, online, and private

Free to use

JSON Flatten is completely free. There is no account to create, no login, and no hidden charge or usage limit.

Runs online in your browser

It is a free online tool that runs entirely in your browser. Nothing to download or install — open the page and start using it right away.

Your data stays private

All processing happens locally on your device. Your input is never uploaded, stored, or tracked, so it never leaves your browser.

How JSON Flatten behaves in detail

These are the specifics of this implementation — the exact ranges, defaults and fixed settings you are working with.

Parameter Value
Join character a single dot between levels — a.b.c
Array handling arrays are treated as leaves and copied whole; nothing inside an array is descended into
Empty objects contribute no keys at all, so a nested {} disappears from the output
Output shape one flat object, re-serialized with 2-space indentation
Non-object root an array root uses its indices as keys — [1,2] becomes {"0":1,"1":2}

Compiled from the implementation of this tool and checked against it by itoolnet.

What JSON Flatten does not do

Knowing the edges of a tool saves more time than another list of its features. These are the cases where it will not do what you might expect.

  • Arrays are not indexed. A structure like {"a":[{"b":1}]} comes back unchanged instead of producing a.0.b, so any payload whose depth lives inside arrays is not flattened at all.
  • Dotted keys are ambiguous and silently collide: {"a.b":1,"a":{"b":2}} flattens to a single key a.b holding 2, so the literal key written in the source is overwritten with no warning and no escaping for dots inside a key.
  • An empty nested object produces nothing rather than a placeholder, so {"a":{}} comes out as {} and the information that a key "a" existed is gone.
  • The whole document has to pass through JSON.parse in one go, so a syntax error anywhere in it yields no flattened output at all rather than a partial flattening of the part that parsed.

Tested and documented by itoolnet, the team that builds and maintains this site.

Share & embed this tool

Writing a guide or article? You are welcome to link to JSON Flatten with the snippet below. It is free, runs entirely in your browser, and needs no signup.