JSON Flattener
Runs locally in your browserFlatten nested JSON into path keys and unflatten it back
Nested JSON
What JSON Flattener does
JSON Flattener turns nested objects and arrays into one level of path keys such as user.address.city or users[0].name, and rebuilds nested JSON from those keys. Flat keys are handy for configuration systems, translation files, spreadsheet columns, search indexes and diffs that are hard to read when data is deeply nested. Strings, numbers, booleans, null, empty objects and empty arrays keep their types, and numbers beyond JavaScript precision such as 9007199254740993 are written with their exact digits.
How to use
- 1.Choose Flatten or Unflatten, then paste JSON, upload or drop one .json file, or load an example.
- 2.Pick the delimiter (. / _ or __) and whether array indexes use brackets (items[0]) or the delimiter (items.0).
- 3.In Flatten mode, choose JSON object, Key=value lines or Environment variables as the output.
- 4.Read the round-trip check and any listed issues; each issue names the exact paths involved.
- 5.Copy the result or download flattened.json, unflattened.json, flattened.txt or flattened.env. Use Unflatten this output to check the reverse direction.
Collisions, conflicts and the round-trip check
Flattening is only reversible when every key parses back to its original path. A key that already contains the delimiter (for example "a.b" with the dot delimiter) or two paths that produce the same flat key are reported with both paths; the first value is kept and nothing disappears without a warning. When unflattening, a key that needs a path to be both a value and an object (user and user.name), an index far past the end of an array, or gaps in an array are reported too, and gaps are filled with null. After every JSON run the tool performs the inverse operation and compares the result, so "Round trip verified" is a real check, not a promise.
Environment variables, limits and privacy
Environment variable names are upper-cased, camelCase words are split with _, accents are removed and any character outside A–Z and 0–9 becomes _, so database.primary.port becomes DATABASE_PRIMARY_PORT. Names starting with a digit get a _ prefix, and names that collide are reported. Key=value and environment output are one-way formats. Object keys that look like integers are listed first because that is how JavaScript orders them, nesting deeper than 256 levels is kept as one value, and inputs over 2 MB are processed when you select the main action. Everything runs in your browser and the JSON is never uploaded.
