Query JSON Files with SQL
Run SQL on JSON and NDJSON files in your browser. Read nested fields, unnest arrays and turn JSON into a clean table you can export as CSV or Parquet.
JSON exports from APIs and logs are nested and hard to analyse in a spreadsheet. DuckDB reads JSON and newline-delimited JSON as tables, turns nested objects into structs you can reach with dot notation, and lets you unnest arrays into rows.
How it works
- Drop a .json or .ndjson file into the SQL Playground.
- Nested objects become STRUCT columns and arrays become LIST columns.
- Use dot notation and UNNEST to flatten, then export the result as CSV or Parquet.
Examples you can copy
Read nested fields
SELECT event_id, "user", type, device.os, device.browser
FROM events;
One row per array item
SELECT event_id, UNNEST(tags) AS tag
FROM events;
Count events per type and device
SELECT type, device.os AS os, COUNT(*) AS n
FROM events
GROUP BY ALL
ORDER BY n DESC;
FAQ
Can SQL read nested JSON?
Yes. DuckDB maps nested objects to STRUCT columns that you query with dot notation (device.os) and arrays to LIST columns you can UNNEST into rows.
Does it support NDJSON / JSON Lines?
Yes. Both a single JSON array and newline-delimited JSON (one object per line) are read as tables.
How do I convert JSON to CSV with SQL?
Select and flatten the fields you want, run the query, then export the result as CSV.
Is my JSON uploaded?
No. The file is read and queried inside your browser.
Open the SQL Playground
Explore the local data workbench ยท Browse all tools