Skip to content

JSON Flattener

Collapse nested JSON into one flat level of dot-notation or bracket keys.

Quick Tool Overview

The JSON Flattener collapses a nested document into a single level, where every key is the full path to a leaf value. Choose dot notation for config loaders or bracket notation for form serialisers.

What it does
Collapses nested JSON into one level of path keys
You give it
A nested JSON document of any depth
You get back
A flat object keyed by dot or bracket paths
Best for
CSV exports, env files, search indexes and analytics payloads
Developer Tools Free, unlimited use No sign-up Runs in your browser

About the JSON Flattener

Flattening rewrites a nested document as one level, where each key is the full path to a leaf value. The object {"user":{"name":"Ada"}} becomes {"user.name":"Ada"}, and an array index becomes part of the path in the same way.

The reason to do it is almost always that something downstream cannot handle nesting. A CSV column header, an environment variable, a spreadsheet import, a search index field, a feature flag store or an analytics event payload all want flat keys. You can choose dot notation, which config loaders prefer, or bracket notation, which is what HTML form serialisers and PHP produce. The JSON Unflattener reverses either form exactly.

Key features of the JSON Flattener

Two notations

Dot notation writes user.address.city; bracket notation writes user[address][city]. Match whatever the consuming system parses.

A custom separator

Swap the dot for an underscore, slash or pipe when your own keys contain dots and the round trip has to stay exact.

Arrays keep their positions

Indexes become path segments, so items.0.name is unambiguous and rebuilds as an array rather than an object.

Empty containers survive

An empty object or array is kept as a leaf value instead of vanishing, which matters when empty and missing mean different things.

Reverses exactly

The JSON Unflattener reads either notation back, so flattening for storage is not a one-way trip.

How to use the JSON Flattener

  1. 1

    Paste the nested JSON

    Any depth of objects and arrays can be flattened.

  2. 2

    Choose a notation

    Dot notation writes user.address.city; bracket notation writes user[address][city].

  3. 3

    Set the separator

    Swap the dot for an underscore or a slash when the consuming system needs one.

  4. 4

    Copy the flat document

    The result is a single-level JSON object, ready to paste or download.

Frequently asked questions

The index becomes a path segment, so items.0.name in dot notation or items[0][name] in bracket notation. The order is preserved, and the Unflattener rebuilds the array from it.

Reviews of the JSON Flattener

What people who use the JSON Flattener think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the JSON Flattener. It takes half a minute and no account.

Write the first review

More developer tools