"category": "utility",
JSON Flattener
"tldr": Paste nested JSON and get a single-level object with dotted paths as keys - ready for CSV export, spreadsheets, and diff-friendly comparison.
Flatten deeply nested JSON into a single-level object where every key is the full dotted path to its value: {"user": {"name": "Ada"}} becomes {"user.name": "Ada"}, and array elements get indexed paths like items.0.sku.
Flattening is the standard prep step before anything tabular: CSV export, spreadsheet analysis, database columns, or feeding analytics tools. It also makes structural comparison trivial - two flattened documents diff key-by-key, which is exactly how our JSON Compare works under the hood.
How to flatten JSON
- 1Paste any JSON object or array.
- 2Every leaf value gets a key that is its full path, joined with dots.
- 3Array positions become numeric path segments (items.0.sku).
- 4Copy the flat object - it converts cleanly to CSV with our JSON to CSV tool.
Convert Nested JSON to Flat JSON in code
import { flatten, unflatten } from "flat"; // npm install flat
const flat = flatten(nested); // {"user.name": "Ada"}
const back = unflatten(flat); // original structureimport pandas as pd
df = pd.json_normalize(records, sep=".") # nested -> flat columnsFrequently asked questions
How do I unflatten - get the nesting back?
Split each key on dots and rebuild: libraries do this reliably - flat (npm) has unflatten(), and pandas json_normalize has inverse patterns. Round-tripping is safe as long as no original key itself contained a dot - check that before flattening.
What if my keys already contain dots?
Then "a.b": 1 and {"a": {"b": 1}} flatten to the same key and become ambiguous. If your data has dotted keys, flatten with a different separator in code (flat supports delimiter options) - this tool uses dots because that is the near-universal convention.
Why flatten before CSV conversion?
CSV cells hold scalars; nested objects otherwise get serialized as JSON strings inside cells. Flattening first turns every nested field into its own column - user.name and user.address.city become two proper columns instead of one JSON blob.
Last updated:
You might also need
Free and in-browser, like everything on JSON Console. Browse all tools →