JSON Flatten

Paste nested JSON and get one flat object, where each key is the full path to a value, such as address.city or tags.0.

How it works

The tool walks the JSON from the top. Each value that is not an object or an array becomes one key in the output, named by the path to it: the keys on the way joined by the separator, and list positions as numbers.

You choose the separator (a dot, a slash or an underscore) and how list positions are written: tags.0 or tags[0]. An empty object or list has no values inside it, so it is kept as {} or [] under its own path rather than disappearing.

Numbers keep their exact digits and keys keep their order. If two values end up with the same key, for example a key that already contains a dot, both are kept and the note under the result names it.

How to use it

  1. 1 Pick a separator. The dot is the most common.
  2. 2 Pick how list items are written: with the separator, as in tags.0, or in brackets, as in tags[0].
  3. 3 Paste your nested JSON into the first box. The flat JSON appears in the second box.
  4. 4 Check the note for the key count and any clashes, then copy or download the result.

Good to know

  • Flat keys are what you need to turn JSON into a spreadsheet, to set environment variables from a config, or to compare two configs line by line.
  • If your keys already contain dots, such as "example.com", pick the slash or the underscore so the paths stay readable and do not clash.
  • Pick tags[0] when the result goes to lodash get and set, or to a form library that reads bracket paths.
  • To turn flat keys back into nested JSON, use JSON Unflatten with the same separator.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Flat keys for nested JSON, and the cases that trip flatteners up

Nested JSON is natural for programs and awkward for almost everything else. A spreadsheet has columns, not trees. Environment variables and many key-value stores take one level of names. A translation platform wants one string per key. Comparing two config files is far easier when each setting sits on one line. Flattening solves all of these by turning every leaf value into a single key that spells out the path to it: {"user": {"address": {"city": "London"}}} becomes {"user.address.city": "London"}.

Arrays get their positions in the path. With the default style, the first tag is tags.0 and the name of the second user is users.1.name. Bracket style writes tags[0] and users[1].name instead, which is the path syntax lodash, JavaScript and many form libraries read. A top-level array works too, giving keys that begin with the position. The separator between object keys can be a dot, a slash or an underscore, and the bracket style ignores the separator for positions.

Two cases trip up simpler flatteners. The first is empty containers. An empty object or list has no leaves, so a naive walk writes nothing for it and the key silently disappears; flatten and then unflatten, and settings: {} is gone. This tool keeps it as a value, "settings": {}, so the round trip is exact. The second is clashes. If a key already contains the separator, such as "a.b" next to an object a with a key b, both produce the key a.b. Rather than dropping one, the tool keeps both and names the clashing keys in the note, so you can pick a separator that tells them apart.

Values come through untouched. The JSON is read with a parser that keeps numbers as the digits you wrote and keys in their original order, so a 20-digit ID or a price written as 19.90 appears in the flat output exactly as it did in the input. The output keys are listed in the same order as the leaves appear in the original document.

Flattening is half of a round trip. JSON Unflatten rebuilds the nested structure from flat keys, turning runs of 0, 1, 2 back into lists. Use the same separator in both directions. Everything happens on this page, so private configuration and customer records never leave your device.

Frequently asked questions

What happens to arrays?

Each item gets its position in the path: tags.0, tags.1 and so on, or tags[0] and tags[1] with brackets. Objects inside arrays are flattened too, so users.0.name is the name of the first user.

What is a clash?

Two different paths that produce the same flat key. For example {"a": {"b": 1}, "a.b": 2} gives a.b twice with a dot separator. Both are kept, in order, but most JSON readers keep only the last. Switching to another separator usually separates them.

Can I flatten a list at the top level?

Yes. A top-level list gives keys that start with the position, such as 0.name and 1.name. A single value on its own, such as a number, has nothing to flatten, and the tool says so.

Is my JSON uploaded?

No. It is flattened in this page and never sent anywhere.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.