How to use the JSON Flatten / Unflatten
Flatten or unflatten JSON in one click:
1
Paste your JSON
Paste any nested JSON object or array to flatten it, or a flat dot-notation JSON object to unflatten it back to nested form.
2
Choose mode and delimiter
Select Flatten or Unflatten. Choose a delimiter: dot (.) is the default, or use underscore (_), slash (/), or hyphen (-) for systems that can't use dots in key names.
3
Click Convert
Get the flattened or restored JSON instantly in the output panel.
4
Copy or download
Copy the result to clipboard or download as a .json file for use in your pipeline or config system.
When to use this tool
Use this whenever you need to bridge the gap between nested JSON and flat key-value systems:
- →Flattening a nested API response before importing into a spreadsheet, CSV, or flat database table
- →Converting nested config objects to environment variable format where keys must be dot-notation or ALL_CAPS flat names
- →Preparing deeply nested JSON for CSV export where each nested field needs to be a separate column
- →Flattening JSON before diffing two config files — flat key-value pairs are far easier to diff than nested structures
- →Unflatten environment variables (e.g. DB__HOST=localhost) back to a nested config object at application startup
- →Normalizing JSON for insertion into a key-value store like Redis or DynamoDB flat attributes
- →Debugging deeply nested JSON by flattening it to see all values in one flat list
Frequently asked questions
Q:What does flattening JSON mean?
Flattening converts a nested JSON object into a single-level object where all keys are dot-notation paths. For example, { "user": { "address": { "city": "London" } } } becomes { "user.address.city": "London" }. Every nested key path becomes a flat string key, making the data easier to store in a flat structure or compare as key-value pairs.
Q:What delimiter is used for flattened keys?
The default delimiter is a dot (.). For example, { user: { name: 'Alice' } } becomes { 'user.name': 'Alice' }. You can change the delimiter to underscore (_), slash (/), or hyphen (-) if your target system cannot use dots in key names — for example, environment variable names often use underscores.
Q:How are arrays handled during flattening?
Array elements are indexed numerically: { "tags": ["a", "b"] } becomes { "tags.0": "a", "tags.1": "b" }. Unflattening reverses this — keys ending in numeric indices are reconstructed as arrays. This handles arrays of primitives cleanly; arrays of objects are also flattened with the full path to each nested field.
Q:What is unflattening used for?
Unflattening reconstructs a nested JSON object from a flat one. This is most useful when config is stored as environment variables with dot-notation names (e.g. DB.HOST=localhost, DB.PORT=5432) and needs to be converted to a nested object ({ db: { host: 'localhost', port: 5432 } }) before passing to an application. It's also useful for importing flat CSV data as nested JSON.
Q:Does flattening change the actual data?
No — only the structure changes. All values remain identical. Flattening and then unflattening with the same delimiter produces a JSON object that is semantically equivalent to the original. The only exception is if the original had keys that already contained the delimiter character — in that case the paths would be ambiguous.
Q:Is my data sent to a server?
No. All flatten and unflatten operations run entirely in your browser. No data is transmitted, logged, or stored anywhere. You can paste sensitive config files safely.