Skip to content
Convert Filez
Data And FormatsRuns in your browser5 min readUpdated July 29, 2026

JSON Flattener

This JSON flattener collapses a deeply nested JSON object into a single level object, turning every nested path into one flat key using dot notation, or whichever delimiter you choose instead. Paste JSON or drop a .json file, pick a delimiter, and get back an object where a value that used to live three levels deep sits under one combined key like address.city or user_address_city. This json flattener is built for exactly that one job rather than a general purpose transformer.

Loading the tool interface
Files never leave your deviceNo upload wait and no queueNo signup, watermark or file limit

Nested JSON is the natural shape for representing related data, but a lot of tooling downstream expects flat keys instead: a spreadsheet has one column per field, an environment variable list has one flat name per value, and some analytics and logging platforms only index top level keys at all. Flattening bridges that gap without you having to manually rewrite the structure by hand.

The whole operation happens in your browser using a small recursive function, so nothing you paste or upload is sent anywhere. A configuration sample or an API response containing production data stays on your device throughout, from the moment you paste it to the moment you copy the flattened result.

When you should flatten nested JSON

Flattening is worth doing whenever the destination expects one key per value rather than a tree, such as preparing data for a spreadsheet column, generating environment variable names from a nested configuration file, or feeding a logging or analytics platform that only indexes flat top level fields rather than searching inside nested objects.

It is also a useful debugging step on its own. A deeply nested API response can be hard to scan for a specific value, and seeing every possible path rendered as one flat key with its value right next to it often makes a large structure much faster to search than paging through several levels of nested braces.

  • Flatten before turning JSON into spreadsheet columns or CSV headers.
  • Flatten to generate environment variable names from a nested configuration file.
  • Flatten for a logging or analytics tool that only indexes flat top level keys.
  • Flatten to make a large nested response easier to scan and search visually.

How this json flattener builds json dot notation keys

Every key in a nested object is combined with the keys of its parent objects, joined by the delimiter you choose, so a document like {"address": {"city": "Oslo"}} becomes {"address.city": "Oslo"} with the default dot delimiter. This continues recursively no matter how many levels deep the nesting goes, so a value four objects deep still ends up as one combined key with all four segments joined together in order.

An array is handled the same recursive way, using the array index as the key segment for that level, so a list like {"tags": ["admin", "staff"]} becomes tags.0 and tags.1 as two separate flat keys. This keeps every individual value addressable by its own unique key rather than collapsing an array into a single stringified blob.

Choosing a delimiter for your flatten json object output

A dot is the default delimiter and the most common convention, matching how nested property access already reads in JavaScript, Python and most templating languages. An underscore is the better choice when the flattened keys are destined to become environment variable names or database column names, since many of those contexts do not allow a literal dot character in an identifier at all.

A colon is occasionally used for keys destined for tools that treat a dot as meaningful in their own syntax, such as some templating engines or query languages, where an unescaped dot in a flat key could be misread as a nested path lookup rather than a literal key name. Whichever delimiter you pick, this json flattener applies it consistently across every level of nesting in the result.

What happens to empty objects, empty arrays and null values

An empty object or an empty array has no keys or indices of its own to flatten into, so this json flattener keeps it as an empty JSON object or array at its own flat key rather than silently dropping it, which would otherwise make it look like that field never existed in the source data at all.

A null value is kept as null under its own flattened key rather than being treated as a nested container with nothing to descend into, since null and an empty object represent two genuinely different things in JSON, and collapsing that distinction would lose information a downstream consumer might actually care about.

JSON.parse first, then one recursive walk

Parsing uses the browser's built in JSON.parse, so a malformed input is reported with the exact character position where the parser stopped rather than a vague failure. Once parsed, a recursive walk visits every key and value, building up the combined path as it descends and writing a new entry into the flat result the moment it reaches a value that is not itself an object or array to descend further into.

Because this all runs as plain JavaScript in your browser tab, there is no size limit imposed by the tool itself beyond the memory available to your browser, and a deeply nested structure with hundreds of fields flattens in a fraction of a second on ordinary hardware.

How to flatten a JSON object

  1. 1

    Add your JSON

    Paste a nested JSON object into the box, or drop a .json file. Nothing leaves your device.

  2. 2

    Choose a delimiter

    Pick a dot, an underscore or a colon to join nested key segments, matching what your destination expects.

  3. 3

    Flatten

    Press flatten. Malformed JSON is reported with the exact character position the parser stopped at.

  4. 4

    Copy or download

    Once flattening succeeds, copy the flat JSON to your clipboard or download it as a .json file.

Related tools worth bookmarking

Sources and further reading

Frequently asked questions

Common questions about the json flattener.

This can happen when your data already contains a key with the delimiter character in it, for example a field literally named address.city alongside a nested address object with its own city field. Both end up sharing the same flattened key, and the later one in traversal order overwrites the earlier one, so renaming the literal key first avoids losing a value silently.

Yes. A dot is the default and most common choice, but an underscore or a colon is available for destinations such as environment variable names or database columns that do not allow a literal dot character inside an identifier.

Each array item is flattened using its numeric index as the key segment for that level, so a three item array under a tags key becomes tags.0, tags.1 and tags.2 as three separate flat keys, keeping every value individually addressable rather than collapsing the array into one string.

No. Every value keeps its original type, and an empty object, an empty array and a null value are all preserved distinctly at their own flat key rather than being silently dropped or merged together, so the flattened result can represent the same data the nested source did.

This tool performs the flattening direction. Reconstructing the original nested shape from flat dot notation keys is a separate operation this page does not currently perform, though the flat keys it produces retain enough structure in their names to make that reconstruction straightforward in code if you need it.

No. This json flattener's recursive function walks the value JSON.parse already built, joining each nested key to its parent with your chosen delimiter entirely inside that same browser tab, so a configuration sample containing production secrets never leaves the tab it was pasted into.

Keep going

More data and formats

View the full category