SmartQueryTools

Flatten NDJSON Files Online

Flatten nested JSON structures in NDJSON files into a flat table directly in your browser. Nested objects are expanded into prefixed columns — no upload required.

How to flatten NDJSON files

  1. Drop your JSON file onto the upload area. The tool finds every top-level key that holds a nested object and previews the first 200 rows.
  2. Read the list of nested columns. Each one is shown with the new column names it will produce, such as location → location_site, location_floor.
  3. Click Flatten. The preview switches to the flattened table.
  4. Click Download JSON to save the result, with _flat added to the file name. If the file has no nested objects, the tool says it is already flat and there is nothing to run.

Your file is processed locally in your browser and is never uploaded. The free limit is 50 MB per file; larger files work if your device has the memory for them.

Worked example

A facilities team pulls a device list from a sensor platform API. Each record looks like {"device_id": "th-01", "location": {"site": "Depot A", "floor": 2}, "battery": 87}, and the spreadsheet they report from needs one plain column per field.

Input (NDJSON)

{"device_id":"th-01","location":{"site":"Depot A","floor":2},"battery":87}
{"device_id":"th-02","location":{"site":"Depot A","floor":1},"battery":64}
{"device_id":"th-07","location":{"site":"Harbour St"},"battery":12}

Settings

  • No options. Every nested object column is expanded one level.

Result

device_idbatterylocation_sitelocation_floor
th-0187Depot A2
th-0264Depot A1
th-0712Harbour StNULL

The location object is replaced by two columns named with an underscore: location_site and location_floor. Plain columns stay first and the expanded columns are added at the end, so battery moves ahead of the location fields. th-07 had no floor key in its location object, so location_floor is null.

Frequently Asked Questions

How many levels of nesting are flattened?

One level per run. Objects nested inside objects become struct columns that you can flatten by running the tool again on the output.

Does flattening change the column order?

Yes. Columns that were already flat come first, in their original order, and the expanded columns are added after them.

What if my file has no nested objects?

The tool reports that no nested structures were detected and that the file is already flat. There is no Flatten button in that case.

Related Tools