Flatten and Unflatten JSON

Turn deeply nested JSON into one level of keys such as user.address.city, ready for a spreadsheet, a translation file or a search index. Rebuild the nested structure from flat keys just as easily.

  • Free
  • Runs in your browser
  • Round-trip safe
  • No sign-up
How it works

How It Works

Flatten or rebuild JSON in three steps.

01

Paste JSON

Nested JSON to flatten, or a flat object to unflatten.

02

Set the separator

A dot by default. Use _ or / if your keys already contain dots.

03

Copy the result

Switching mode moves the result to the input, so you can check the round trip.

About

What does flattening JSON mean?

Flattening walks through every nested object and array and writes each value under one key that records its path: {"user": {"name": "Ana"}} becomes {"user.name": "Ana"}. Flat data fits places that only understand one level, such as spreadsheet columns, environment variables, i18n translation files and some search and logging tools. Unflattening splits the keys again and rebuilds the original shape.

If a key itself contains the separator, such as "version.major" as a single key, unflattening splits it into two levels. Pick a separator that never appears in your keys.

Arrays by index

Array items get their position in the key: tags.0, tags.1, or tags[0] with the bracket option.

Empty values kept

Empty objects and arrays are kept as {} and [] so unflattening gives back exactly the same structure.

Any separator

Dot, underscore, slash, double underscore or anything else you type.

Arrays restored

When unflattening, number keys become arrays again unless you untick the option.

Features

Why Use This JSON Flattener

Flat keys and back, without writing a script.

Two directions

Flatten and unflatten with the same settings.

Two array styles

a.0.b or a[0].b, to match the library or tool you feed it to.

Lossless

Empty objects, empty arrays and null values survive the round trip.

Private

Converted in your browser.

✓ No Registration✓ Free✓ Browser-based✓ Text Stays Local
FAQ

Frequently Asked Questions

Questions people ask about the JSON Flatten & Unflatten tool.

Flatten it first, then convert it with JSON to CSV or JSON to TSV. Each flat key becomes its own column, such as user.name and user.email.