JSON flattener — nested JSON to dot notation and back

Flatten nested JSON into single-level dot-notation keys, or rebuild the nested structure from flat keys. Runs in your browser.

  • No upload
  • Round-trips
  • No signup

How this tool fits your workflow

More in this category →

What flattening actually does

Flattening turns a tree into a table. Every leaf value in a nested JSON document gets a single key that describes the full path to reach it, so a document of any depth becomes one level deep.

This matters because a lot of systems only accept flat key-value data. Environment variables, CSV columns, many feature-flag services, form-encoded payloads, analytics event properties, and translation files all want flat keys. Flattening is how you get a nested config into them without restructuring by hand.

Worked example: a nested config

Take a small configuration document with two levels of nesting and an array:

  1. Paste the nested JSON into the left pane. Conversion runs as you type — there is no button to press.
  2. Read the flattened result on the right. Five leaves in, five keys out.
  3. To reverse it, switch to Unflatten and paste the flat JSON back in.
  4. Compare the result against your original. A flatten then unflatten cycle returns the document unchanged, which is the quickest way to confirm nothing was lost.
Nested pathFlattened keyValue
user → nameuser.nameAda
user → address → cityuser.address.cityLondon
user → address → postcodeuser.address.postcodeE1 6AN
tags → [0]tags[0]admin
tags → [1]tags[1]beta

How the path syntax works

  • A dot separates object levels: a.b.c means the value at a → b → c.
  • Brackets mark array positions: items[0].name is the name field of the first element.
  • Empty objects and empty arrays are kept as leaves rather than disappearing, so {} and [] survive the round trip.
  • Values keep their JSON types. Numbers stay numbers, booleans stay booleans, null stays null — only the keys change.

Common mistakes

  • Assuming flattening reduces size. It usually increases it, because every leaf now carries its full path. Flattening is for compatibility, not compression.
  • Flattening a deeply nested document for storage. Once flat, you cannot query a subtree without string-prefix matching, which is slower and more fragile than working with the nested form.
  • Expecting sparse arrays to survive. If a flat document has items[0] and items[2] but no items[1], unflattening produces a hole in the array. Check for that before relying on the length.
  • Feeding the output straight into a system with key-length limits. Deep nesting produces long keys, and some databases cap column or field name length.
  • Forgetting that key order is not guaranteed. JSON object key order is preserved by most engines in practice but is not part of the specification, so do not depend on it for anything important.

When not to use this

Related workflow

Flattened JSON is often a step toward tabular data. Once each record is one level deep, the CSV and JSON converter can turn an array of them into a spreadsheet with one column per key.

If you are flattening in order to load values into environment variables, the ENV to JSON converter handles the dotenv side of that pipeline.

To check that a flatten and unflatten cycle really did return the original, the JSON diff tool compares two documents structurally, so key reordering does not register as a difference.

Frequently asked questions

What does flattening JSON mean?
It converts a nested structure into a single level, where each key is the full path to a value. { "user": { "name": "Ada" } } becomes { "user.name": "Ada" }. Nothing is lost — the path encodes the structure.
Can I get the nested structure back?
Yes. Switch to Unflatten and paste the flat JSON. The tool reads dot separators as object nesting and bracket indices as array positions, so a flatten followed by an unflatten returns the original document.
What happens to arrays?
Array elements use bracket notation: tags[0], tags[1]. On unflatten, numeric bracket segments rebuild arrays rather than objects with numeric keys.
What if my keys already contain dots?
That is the one case flattening cannot round-trip. A key literally named "user.name" is indistinguishable from nesting once flattened. See the limits section below.
Is my data uploaded?
No. Parsing and conversion run in your browser with JavaScript. Nothing is sent to a server, so config files and API payloads stay on your machine.