JSON Flattener
Flatten nested JSON into dotted, underscore, or bracket-notation keys, and unflatten flat key-value maps back into nested JSON objects.
Loading tool...
What is JSON Flattener?
JSON Flattener is a free in-browser tool that converts nested JSON objects into a flat list of key-value pairs and vice versa. Choose a separator style (dot, underscore, slash, bracket, or custom) that matches your target system β env vars, MongoDB fields, structured logs, or config files β and copy the result instantly.
Key Benefits
- Convert nested API responses into env-var-friendly flat keys
- Rebuild nested JSON from flat key-value lists without scripting
- Inspect deeply nested data via flat key paths and inferred types
- Reconstruct objects from Redis HGETALL, logs, or ENV exports
- Keep data private with fully local browser processing
Common Use Cases
- β’Turn nested config files into flat env vars for Docker and shell scripts
- β’Convert flat CSV/TSV-style rows into nested JSON for APIs and storage
- β’Flatten MongoDB or Elasticsearch query results for spreadsheet review
- β’Normalize structured logs into a single key=value format for analysis
- β’Prepare configuration snapshots that round-trip between flat and nested forms
Flatten or Unflatten JSON
- Pick a direction: Choose the Flatten tab to collapse nesting or Unflatten to rebuild JSON from key = value lines β a matching sample loads for each mode.
- Choose a separator: Select dot, underscore, slash, bracket notation, or a custom one like :: β keys containing the separator are backslash-escaped so nothing collides.
- Paste your data: Drop nested JSON or flat lines into the input; Flatten shows a table of key, value, and type per leaf, while Unflatten prints the rebuilt JSON with arrays from numeric indices.
- Copy the result: Press Copy to take the flat lines or pretty-printed JSON, and fix anything the error message points out, such as invalid JSON or a line missing its = sign.
Key Features
- Bidirectional: flatten JSON to flat keys and unflatten flat maps back into nested JSON.
- Four built-in key separators (dot, underscore, slash, bracket) plus a custom separator option.
- Smart value-type inference: strings, numbers, booleans, null, and nested objects/arrays.
- Handles arrays naturally with bracket notation such as tags[0], tags[1].
- Side-by-side table view of flattened key, value, and detected type for quick review.
- Runs entirely in your browser with no data uploaded.