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
Flatten or rebuild JSON in three steps.
Paste JSON
Nested JSON to flatten, or a flat object to unflatten.
Set the separator
A dot by default. Use _ or / if your keys already contain dots.
Copy the result
Switching mode moves the result to the input, so you can check the round trip.
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.
Convert PDF Files and File Formats
Find the perfect online tool to combine PDF files, compress documents, and handle your daily workflow effortlessly.
PDF Tools
All your PDF needs in one place
- Merge PDF
- Organize PDF
- Split PDF
- Compress PDF
- Convert to Word
- Convert to Image
Image Tools
Edit and optimize your images
- Resize Image
- Compress Image
- Convert Format
- Crop Image
- Add Watermark
- Remove Background
Word Tools
Work with Word documents
- Convert to PDF
- Merge Documents
- Split Documents
- Compress File
- Edit Text
- Add Watermark
Excel Tools
Process Excel spreadsheets
- Convert to PDF
- Convert to CSV
- Merge Sheets
- Split Sheets
- Compress File
- Clean Data
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.
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.
A dot is the most common and matches libraries like flat (npm) and lodash's get(). Use __ for environment variables, since dots are not allowed in their names on many systems.
Keys like items.0 become arrays only when Turn number keys into arrays is ticked. With it unticked, "0" stays an object key.
Yes. Keys appear in the order they are found, depth first, and unflattening rebuilds them in the same order.
Related Text & Developer Tools
More small utilities that run in your browser.