Flatten JSON

Flatten nested JSON objects into a CSV table (dot notation), or nest dotted CSV columns back into JSON.

Drop a file or click to browse

or paste data below

How Flatten JSON works

Flatten: nested objects become dotted columns

Every nested object is expanded into its own columns, with the path joined by dots, at any depth: {"user": {"address": {"city": "Pune"}}} becomes a user.address.city column. Columns are collected across all records, so a field that only some records have still gets a column, with blank cells for the rest.

This differs from JSON to CSV, which keeps each top-level key as one column and stores nested objects as JSON text. Flatten when you want to filter, sort, or chart nested fields in a spreadsheet. Our guide flattening nested JSON for spreadsheets discusses the trade-offs.

How arrays are handled

Arrays are not spread into extra rows, which would multiply every other field. An array of simple values is joined with commas into one readable cell, so ["admin", "beta"] becomes admin, beta. An array of objects, such as order lines, is kept as JSON text in a single cell so no structure is lost. An empty array is written as [], and null becomes a blank cell.

If you need one row per array element, for example one row per order line, that is a different operation (an unnest or explode). It is easiest in SQL: load the file into DB in Browser or a tool with JSON functions.

Nest: back from CSV to JSON

Switch to Nest mode and paste a CSV whose headers use dots. Each dotted header is rebuilt into nested objects, so user.name and user.email end up together under user. Cells that hold JSON arrays or objects, such as the ones Flatten produced, are parsed back into real arrays and objects.

Other values come back as strings, and comma-joined arrays stay as a single string because a comma could just as well be part of the text. Round-tripping is exact for objects and for arrays of objects; arrays of simple values need a split in your own code.

Example

Nested fields get dotted columns; the tags array is joined into one cell and the orders array of objects is kept as JSON text.

JSON input
[
  {
    "id": 1,
    "user": { "name": "Ana", "address": { "city": "Pune" } },
    "tags": ["admin", "beta"],
    "orders": [{ "sku": "A1" }, { "sku": "B7" }]
  },
  { "id": 2, "user": { "name": "Raj" }, "tags": [] }
]
Flattened CSV
id,user.name,user.address.city,tags,orders
1,Ana,Pune,"admin, beta","[{""sku"":""A1""},{""sku"":""B7""}]"
2,Raj,,[],

How to use Flatten JSON

  1. 1

    Choose Flatten (JSON to CSV) or Nest (CSV to JSON).

  2. 2

    Paste the JSON array or the CSV with dotted headers, or drop a file.

  3. 3

    Check the generated columns or the rebuilt structure.

  4. 4

    Copy or download flattened.csv or nested.json.

When to use it

API data in spreadsheets

Turn nested API responses into a flat sheet where every nested field can be filtered and sorted.

Editing JSON config in a table

Flatten, edit values in a spreadsheet, then nest the CSV back into JSON.

Flatten JSON questions

Can I use a separator other than a dot?

No, column paths always use dots. Rename the columns afterwards with Column Tools, or replace dots in the header line before nesting.

Why is an array of objects still JSON in one cell?

Expanding it into rows would duplicate every other field for each element. Keeping it as JSON preserves the data so it can be processed separately.

Does key order stay the same?

Columns follow the order fields are first seen across records, depth-first within each object.

Questions about privacy, file size, or accounts are answered on the FAQ page.

Other tools in the same category

Search all tools