JSON Flatten

Collapse deeply nested JSON into a single-level object where each key is a dot-notation path — for example, user.address.city — or reverse the process to expand a flat structure back into its nested form. Array indices are included in the path, and the stats panel shows how many top-level keys map to how many flat keys. Processing is instant and entirely client-side.

Input

JSON

Mode

Options

Auto-converting…
Output

Flattened JSON

What is JSON Flatten Tool?

Nested JSON is intuitive for representing hierarchical data, but it is a problem for tabular systems. BigQuery and Redshift require flat column names. CSV headers cannot encode nesting. Elasticsearch mappings become complex with nested objects. Key-value stores like Redis expect flat string keys. Flattening collapses a nested JSON structure into a single-level object where each key is the full dot-notation path to its value: {"user":{"name":"Alice"}} becomes {"user.name":"Alice"}. This tool does that transformation with configurable separator characters, optional maximum flatten depth, and both dot-notation and bracket-notation array index styles. An unflatten mode reverses the process — useful for restoring objects from flat key-value stores or environment variable configurations back to their original nested form.

How to Use

  1. 1

    Paste Your Nested JSON

    Paste a nested JSON object or array into the input panel. The tool accepts any depth of nesting — objects within objects, arrays of objects, and mixed structures.

  2. 2

    Configure Flatten Options

    Set the key separator (default: dot), choose a maximum flatten depth, and decide how array indices are handled (dot notation like items.0 or bracket notation like items[0]).

  3. 3

    Flatten the Structure

    Click "Flatten". The tool recursively walks the JSON tree and produces a single-level object where every leaf value is accessible via its full dot-notation path as the key.

  4. 4

    Copy the Flat JSON

    Copy the flat key-value JSON for use as BigQuery insert data, Elasticsearch document fields, CSV column headers, or config diff comparison — or download it as a .json file.

Common Use Cases

Data Pipeline Normalisation

Flatten deeply nested API responses into flat key-value structures before loading into columnar databases like BigQuery, Redshift, or Snowflake that do not support nested JSON natively.

CSV / Spreadsheet Export Prep

Before converting JSON to CSV or Excel, flatten nested objects so every value maps to its own column rather than embedding sub-objects as raw JSON strings in cells.

Elasticsearch Indexing

Elasticsearch expects flat or semi-flat documents for efficient full-text indexing. Flatten nested JSON documents using dot notation before indexing to improve query performance and mapping accuracy.

Config Diff & Debugging

Flatten two JSON config objects to compare them line by line. Dot-notation keys make it easy to spot exactly which nested setting changed without visually scanning indented structures.

Conversion Examples

Nested Object → Dot-Notation Keys

Nested keys are joined with dots to produce a single-level flat object.

Input JSON

{
  "user": {
    "id": 1,
    "name": "Alice",
    "address": {
      "city": "London",
      "zip": "EC1A"
    }
  }
}

Output CSV

{
  "user.id": 1,
  "user.name": "Alice",
  "user.address.city": "London",
  "user.address.zip": "EC1A"
}

Array Values → Indexed Keys

Array elements become keys suffixed with their zero-based index.

Input JSON

{
  "tags": ["javascript", "nodejs", "api"],
  "scores": [95, 87, 92]
}

Output CSV

{
  "tags.0": "javascript",
  "tags.1": "nodejs",
  "tags.2": "api",
  "scores.0": 95,
  "scores.1": 87,
  "scores.2": 92
}

Frequently Asked Questions