JSON Flatten & UnflattenConvert nested JSON to flat key-value pairs and back

Turn nested JSON into flat keys like user.profile.name, or rebuild the original structure from flat keys. Pick the delimiter and array style, then copy the result as JSON or CSV.

Your input is never sent anywhere.

Details

Mode

Options

Delimiter

Array style

Nested JSON input

Result

{
  "user.id": 1024,
  "user.profile.name": "Jane Doe",
  "user.profile.age": 28,
  "user.profile.address.state": "CA",
  "user.profile.address.city": "San Francisco",
  "user.tags[0]": "admin",
  "user.tags[1]": "editor",
  "user.active": true
}

Flat keys

8

Max key depth

4

Arrays

1

Output size

246 B

TIP

Note the delimiter and array style you used. To get the original structure back, unflatten with the same delimiter.

What Is a Flattened JSON Object?

Flattening turns a nested JSON object into a single level of key-value pairs. Each key is the full path to a value, such as user.profile.name. Unflattening does the opposite: it reads those paths and rebuilds the nested objects and arrays.

Flat keys are easier to scan, sort, compare, and load into tools that expect one value per row. Nested JSON is easier for code to work with. This page converts in both directions, with a choice of delimiter, array style, and depth limit.

Everything runs in your browser. The JSON you paste is not uploaded.

Common Uses: API Responses, Config Files, and Spreadsheets

Reading an API response as a list of paths

Flatten a deeply nested response to see every key path and value in one list. It is a quick way to find where a field lives before you write code to read it.

Moving data into a spreadsheet

Flatten the JSON, switch to the table view, and copy it as CSV. You get a key and value column that you can sort and filter.

Converting localization files

Translation files are often stored either as nested objects or as flat keys like checkout.button.pay. Convert between the two formats in either direction.

Rebuilding objects from flat keys

Environment-style settings or form fields with names like server.port can be unflattened into a nested object to check the structure before you use it.

How to Convert Nested JSON to Flat Key-Value Pairs

  1. Choose Flatten or Unflatten.
  2. Paste your JSON, or click Load sample to see an example.
  3. Pick a delimiter and an array style. In Flatten mode you can also keep arrays as values or set a max depth.
  4. Review the result in JSON or Table view.
  5. Click Copy JSON, Copy CSV, or Download .json.

Note: The JSON you paste stays in your browser and is not uploaded.

Limits and Edge Cases to Know

  • Only strict JSON is accepted. Comments, trailing commas, single quotes, and unquoted keys cause a parse error.
  • Numbers are read as JavaScript numbers, so integers larger than 9,007,199,254,740,991 can lose precision.
  • In Unflatten mode, if two keys point to the same path (for example a and a.b), the one that appears later in the input overwrites the earlier one.
  • Empty path segments are skipped when keys are split, so with the dot delimiter a..b is read the same as a.b.
  • Empty arrays and empty objects are kept as [] and {} values. A single top-level value appears under the key (root).

Example: Nested Input and the Resulting Dot-Notation Keys

With the dot delimiter and bracket array style, the sample input on this page produces keys like these (selected rows).

Flat keyValueWhere it comes from
user.profile.name"Jane Doe"Object property, 3 levels deep
user.profile.address.city"San Francisco"Object property, 4 levels deep
user.tags[0]"admin"Array item at index 0
user.tags[1]"editor"Array item at index 1
user.activetrueBoolean, 2 levels deep

With the delimiter array style, user.tags[0] becomes user.tags.0. A different delimiter replaces the dots in the same way.

Delimiters, Array Styles, and How Unflattening Rebuilds Arrays

How the conversion rules work, and how to choose settings that round-trip cleanly.

Choosing a delimiter

The dot is the default, and keys like a.b.c are widely recognized. Underscore and slash also work. If your own key names contain the delimiter, such as first_name or example.com, unflattening cannot tell which separators are yours. In that case use a custom delimiter that never appears in your keys, such as ::.

Bracket style vs. delimiter style for arrays

Bracket style writes an index as a.b[0].c, which makes it easy to see where an array starts. Delimiter style writes a.b.0.c, so arrays and objects look the same. Unflatten mode accepts both and treats [0] as one more path step.

How unflattening decides what becomes an array

After the keys are split into a tree, any object whose keys are exactly 0, 1, 2… in order with no gaps is converted to an array. Keys with gaps (0 and 2) or leading zeros (01) stay as object keys. You can turn this off with Rebuild arrays from 0, 1, 2… keys if you want those objects left as they are.

Keeping arrays whole and limiting depth

Keep arrays as values leaves each array intact under its key instead of splitting it by index. Max depth stops flattening after a set number of levels and keeps the remaining part as a nested value. Each object key or array index counts as one level.

What the CSV output contains

Copy CSV produces a header row (key,value) followed by one row per flat key. String values are written as they are, and other values are written as JSON. It is a list of paths and values, not a table with one column per field.

Common Problems and Fixes

Unflatten returns the same flat keys

The data was flattened with one delimiter and unflattened with another, so keys such as user_name are never split.

💡 See the solution▼
Select the same delimiter in both directions. If you used a custom delimiter, enter it exactly, including every character.

Keys with dots or underscores get split into extra levels

A key like api.example.com or first_name is cut apart when it matches the delimiter during unflattening.

💡 See the solution▼
Choose a delimiter that does not appear in any of your key names. A custom value such as :: is a safe choice for most data.

An object with numeric keys turns into an array

An object whose keys are 0, 1, 2 in order, such as a lookup table of IDs, is rebuilt as an array in Unflatten mode.

💡 See the solution▼
Turn off the Rebuild arrays from 0, 1, 2… keys option. Keys with gaps (0, 2) or leading zeros (01) are not converted in any case.

Invalid JSON error on input that looks fine

The text uses JavaScript object syntax, such as single quotes, unquoted keys, trailing commas, or comments, which JSON does not allow.

💡 See the solution▼
Use strict JSON: double quotes around every key and string, no trailing commas, and no comments. The error text comes from your browser's JSON parser, so its wording varies between browsers.

Unflatten says it needs a flat JSON object

The input is an array, a string, or a number. Unflatten mode expects an object with one key per path.

💡 See the solution▼
Wrap the data in an object with path keys, for example {"user.name": "Jane"}. Or switch to Flatten mode if your data is already nested.

Frequently Asked Questions About Flat JSON Keys

Q.What does it mean to flatten JSON?

Q.

A. Flattening converts a nested JSON object into a single level of key-value pairs. Each key is the full path to a value, such as user.profile.name. Arrays are expanded by index, so a tags array becomes tags[0], tags[1], and so on.

Q.How do I unflatten JSON back into a nested object?

Q.

A. Switch to Unflatten mode, paste a flat JSON object, and select the same delimiter that was used to flatten it. Each key is split at the delimiter, and bracket indexes such as tags[0] are read as path steps. An object whose keys are 0, 1, 2 and so on, with no gaps, is rebuilt as an array.

Q.Which delimiter should I use?

Q.

A. The dot is the default and works for most data. If your original keys already contain dots (such as domain names) or underscores (such as snake_case names), pick a delimiter that never appears in them, for example a custom value like ::. Otherwise unflattening will split those keys into extra levels.

Q.What is the difference between bracket and dot array notation?

Q.

A. Bracket style writes an array index as tags[0]. Delimiter style writes it like an object key, as tags.0. Unflatten mode reads both. If another tool will consume the output, match the style that tool expects.

Q.Can I keep arrays intact or limit how deep the flattening goes?

Q.

A. Yes. In Flatten mode, turn on Keep arrays as values to leave each array whole under its key, or set Max depth to stop at a given level. Anything deeper stays as a nested value. Each object key or array index counts as one level.

Q.How do I get flattened JSON into CSV or a spreadsheet?

Q.

A. In Flatten mode, click Copy CSV. You get two columns, key and value, with one row per flat key. Values containing commas, quotes, or line breaks are quoted. Paste the text into a file saved with a .csv extension and open it in your spreadsheet app. The result is a key-value list, not one column per field.

Q.What happens to empty objects and empty arrays?

Q.

A. They are kept as values: an empty array appears as [] and an empty object as {} under its key. If the whole input is a single value such as a number or a string, it appears under the key (root).

Q.Is my JSON uploaded to a server?

Q.

A. No. The conversion runs in JavaScript in your browser. The text you paste is not sent to a server or saved.

Q.Why does the page slow down with a very large file?

Q.

A. The input is parsed and converted in your browser every time it changes, so very large JSON can make typing and scrolling sluggish. Trim the input to the part you need, or convert it in smaller pieces.

User Feedback & Request

Your feedback
makes this tool better.

Tell us which features you'd like, what should be fixed, or which new tool you'd like to see. An engineer reads every submission and uses it to guide development.

Send feedback