JSON Flattener
Turn nested JSON into dot or bracket key paths, or rebuild JSON from flat rows.
Nested JSON
Flat rows
Paste JSON to flatten it
Results update as you type. Nothing leaves your browser.
Details
Flattening turns each nested value into one path = value row, with a type column and JSON-literal values. Dot notation escapes literal dots, bracket notation quotes string keys, and a custom separator can be any single punctuation character. Arrays can be expanded into indices, kept as JSON text, or skipped. The Unflatten mode reads those rows back, rebuilds contiguous numeric segments as arrays, preserves null and empty containers, and reports exactly which paths differ when a round trip is lossy.
More examples
Flatten a nested profile
Input: {"user":{"name":"Ada","address":{"city":"İstanbul"}},"active":true}
Output:
user.name = "Ada"
user.address.city = "İstanbul"
active = trueEach leaf gets a single path; strings keep their JSON quotes and Unicode characters are preserved.
Handle a key containing a dot
Input: {"a.b":1,"items":[{"price":10}]}
Dot output: a\.b = 1 / items[0].price = 10
Bracket output: ["a.b"] = 1 / items[0].price = 10Dot notation escapes the literal dot, while bracket notation quotes the whole key so it cannot collide with the separator.
Keep an array as one value
Input: {"matrix":[[1,2],[3,4]]}
Output: matrix = [[1,2],[3,4]]
Unflatten result: {"matrix":[[1,2],[3,4]]}The Keep as JSON text array policy emits a single row whose JSON value is parsed back into a real array.
Rebuild rows into JSON
Input:
user.name = Ada
items[0].price = 10
empty = {}
Output: {"user":{"name":"Ada"},"items":[{"price":10}],"empty":{}}Bare text becomes a string, [0] becomes an array index, and the {} marker restores the empty object.
Examples
Nested object to dot rows
{"user":{"name":"Ada","address":{"city":"İstanbul"}},"active":true}user.name = "Ada"
user.address.city = "İstanbul"
active = trueEach leaf gets one path; Unicode text is preserved and the boolean stays a JSON literal.
Dotted keys in bracket notation
{"a.b":1,"items":[{"price":10}]}["a.b"] = 1
items[0].price = 10Quoting string segments keeps the dot inside the first key from being read as a path separator.
Arrays as JSON text
{"matrix":[[1,2],[3,4]]}matrix = [[1,2],[3,4]]The Keep as JSON text array policy emits a single row; unflatten parses the value back into a real array.
Rows back to nested JSON
user.name = Ada
items[0].price = 10
empty = {}{"user":{"name":"Ada"},"items":[{"price":10}],"empty":{}}Bare Ada becomes a string, [0] becomes an array, and the empty-object marker rebuilds the empty key.
About this tool
The JSON Flattener turns a nested document into one row per leaf: a path, a JSON-literal value, and a type. A payload such as {"user":{"name":"Ada"},"tags":["vip"]} becomes user.name = "Ada" and tags[0] = "vip". Every value keeps its JSON spelling — strings are quoted, numbers and booleans are bare, and null stays null — so the rows are not a lossy string dump. Empty objects and arrays produce marker rows ({} and []), which means the key itself survives a round trip instead of disappearing.
Three path grammars are available. Dot notation writes user.address.city and backslash-escapes literal dots, separators, backslashes, whitespace and equals signs in keys, so a key named a.b becomes a\.b. Bracket notation quotes every string segment, giving ["a.b"][0] for an array item under a dotted key; it is the safest grammar for keys that contain punctuation. Custom notation uses one character of your choice, such as / or :, with the same escaping rules as dot notation.
Arrays can be expanded with indices, kept whole as JSON text, or skipped entirely. Expanded indices are rebuilt as arrays when their numeric segments run contiguously from zero; escaped digits such as \0 and non-contiguous indices stay object keys, and a warning explains the choice. Numeric object keys are escaped by default in dot and custom modes precisely so an object with keys "0" and "1" does not quietly turn into an array. Bracket [0] segments always mean array indices.
The Unflatten direction reads path = value rows and rebuilds nested objects and arrays. Values are parsed as JSON literals, so bare 1 is a number while "1" is a string; text that is not valid JSON is kept as a string with a warning. Blank lines and # comments are ignored, and the tool's own key = value export is re-ingestible without edits. A round-trip check flattens, rebuilds and flattens again, reporting the exact paths that changed if your settings are lossy.
You can filter rows by path or value text, narrow them by type, sort them naturally or lexicographically, and export the full set as key = value, CSV, TSV, JSON Lines or a single flat JSON object. Only the first 500 matching rows are painted; exports always contain every row. Input is capped at 10 MB, files are read in slices, and all parsing, rebuilding and exporting happen inside your browser tab.
What this tool does not do
- Input is capped at 10 MB; larger documents must be split before flattening.
- Custom separators are limited to one character, excluding backslash, equals sign and whitespace.
- At most 500 rows are painted in the table; exports always include every row.
- Skipping arrays is intentionally lossy and will not round-trip those nodes; empty containers and depth-limited subtrees are preserved.
- CSV, TSV, JSON Lines and flat JSON are one-way exports for other systems; key = value is the format this tool can re-ingest.
- Processing runs on the main thread, so extremely large documents can pause typing while a recompute finishes.
- Keys that contain line breaks should use bracket notation; a one-line key = value row cannot carry a literal newline in dot or custom notation.
How to use this tool
Pick a direction
Use Flatten for a nested JSON document or Unflatten for path = value rows. Both modes update as you type.
Choose a path grammar
Dot notation is compact, bracket notation quotes dotted keys, and custom notation uses a single separator character such as / or :.
Set array and depth options
Expand arrays into indices, keep each array as JSON text, or skip arrays. A depth limit keeps deeper subtrees as JSON instead of adding more rows.
Paste or upload
Paste text, use Paste from the clipboard, or load a JSON / text file. Up to 10 MB is accepted; files are read in chunks.
Filter, sort and export
Narrow rows by text or type, sort them, then copy or download as key = value, CSV, TSV, JSON Lines or a flat JSON object.
Check the round trip
Click Check round trip to rebuild the rows and compare them with the original. Any diverging paths are listed in the output.
Use cases
Spreadsheet and CSV preparation
Turn API responses into one path per column before exporting to CSV or TSV, with a stable path grammar you can document for downstream users.
Key-value stores and database columns
Load a flat path → value map into Redis-like stores, environment-style configs or a two-column staging table, then copy the flat JSON object export.
Config diffs and reconstruction
Flatten large config dumps for side-by-side review, edit the path = value lines, and unflatten them back into nested JSON with a single click.
Path and value grammar
| Form | What it means |
|---|---|
| Dot notation | user.address.city; a literal dot in a key is written a\.b, and an all-digit key is written \0 by default |
| Bracket notation | ["user"]["a.b"][0] — every string key is quoted, and [0] is always an array index |
| Custom separator | One character (for example /), escaped the same way as dots: a\/b |
| Empty container | path = {} or path = [] marker rows, re-read as empty objects and arrays |
| JSON-literal value | "Ada" stays a string, 12 stays a number, true and null stay bare; no extra quoting |
| Unflatten input | path = value lines; = inside a quoted value is safe, and blank lines or # comments are ignored |
| Exports | key = value (re-ingestible), CSV, TSV, JSON Lines, or one flat JSON object |
Rows are displayed with quoted strings by default; turn on Readable values to show strings without their JSON quotes in the table only.
Common mistakes
Mistake:Assuming numeric paths are always arrays.
Fix:Dot segments such as 0 and 1 rebuild as an array only when they are contiguous from zero. Escaped digits (\0) and bracket-free object keys stay strings; turn off Numeric segments become arrays to keep every numeric segment as a key.
Mistake:Quoting values that should stay numbers or booleans.
Fix:Values are JSON literals: 2, true and null are bare, while "2" is a string. If a bare word is not valid JSON, the tool keeps it as text and tells you on the output.
Mistake:Using dot notation for keys full of punctuation.
Fix:Switch to bracket notation. It quotes every string key, so a key like a.b or a key containing a separator cannot collide with the path grammar.
Mistake:Expecting skipped arrays to round-trip.
Fix:Skip arrays removes those nodes and reports a warning; use Expand with indices or Keep as JSON text when the data must survive a rebuild.
Frequently asked questions
How are arrays handled when flattening?
By default every array item gets an indexed path, such as items[0].price or items.0.price. Choose Keep as JSON text to emit one row whose value is the whole JSON array, or Skip arrays to omit array nodes entirely — skipping is lossy and is reported in the output. When rows are rebuilt, numeric path segments become array indices only when they run contiguously from 0; gaps and non-contiguous numbers stay object keys with a warning.
What happens to keys that contain dots?
Dot notation escapes literal dots with a backslash: a key named a.b becomes a\.b, and the unflatten parser reads it back as one key. Bracket notation is simpler for punctuation-heavy keys: it quotes every string segment, so the same key appears as ["a.b"] and can never be mistaken for a path separator. Custom separators use the same backslash escaping as dot notation.
Can I convert the output to CSV?
Yes. The Export selector offers CSV, TSV, JSON Lines and a single flat JSON object in addition to the default key = value format. CSV and TSV include path, value and type columns with proper quoting; JSON Lines writes one JSON object per row; the flat JSON object is a single map from paths to typed values. Only key = value can be fed back into Unflatten, because it preserves the exact JSON-literal value spelling.
How does unflatten know a key is an array index?
Bracket [0] segments are always array indices. In dot or custom notation, an all-digit segment is treated as an index only when the digits at that level run contiguously from 0 (0, 1, 2…); otherwise they stay string keys and a warning explains the rule. Digits escaped with a backslash, such as \0, always stay object keys. You can also turn off Numeric segments become arrays to keep every dot-style number as a key.
Is null different from a missing key?
Yes. A null property produces a row with the JSON literal null and the type null. A missing key produces no row at all. Empty objects and arrays also produce marker rows ({} and []), so unflatten can recreate the key with its empty value instead of dropping it. This is why a flatten → unflatten round trip keeps nulls and empty containers intact.
Why did my string become a number when I rebuilt the JSON?
Values are parsed as JSON literals: bare 1 becomes the number 1, while "1" stays the string "1". The flattener always writes strings with JSON quotes, so its own key = value export round-trips correctly. If you hand-write bare text that is not valid JSON, the tool keeps it as a string and shows a warning with the line number instead of guessing a type.
What are the size and display limits?
Input is capped at 10 MB and files are read in slices rather than one large buffer. Up to 500 matching rows are painted in the table so the page stays responsive; exports and copy actions always contain every row. Use the filter and type controls to find the rows you need, and pick an export format for the full dataset.
References & standards
Related tools
Base32 Encoder / Decoder
Encode and decode Base32 (RFC 4648) with hex input mode and Crockford variant. Handles TOTP secrets. Runs in-browser.
Base58 Encoder / Decoder
Convert hex or text to Base58 and back, with Base58Check validation (version byte + checksum). IPFS CIDs too. In-browser.
Base64 Toolbox
Professional Base64 workspace for text, files and images with Base64URL, MIME, Data URI, strict validation, image preview and ready-to-use snippets.
BibTeX to JSON Converter
Parse .bib bibliographies into structured JSON with authors, months, macros and LaTeX cleanup, all in-browser.
C# to VB.NET Converter
Convert a subset of C# — classes, methods, variables, loops — into VB.NET
CSV Data Viewer
Paste CSV and inspect it as a sortable, searchable table with delimiter detection and inline export.