← Back to DuckDB Browser FAQs
How to Query CSV and JSON Files
The DuckDB Browser can load and query CSV, JSON, and newline-delimited JSON (NDJSON) files directly in your browser.
Loading CSV Files
- Open the DuckDB Browser.
- Drop your
.csvfile onto the drop zone. - DuckDB auto-detects the delimiter, header row, and column types using
read_csv_auto(). - Data is loaded into the
importedtable.
Loading JSON Files
- Drop your
.json,.jsonl, or.ndjsonfile onto the drop zone. - DuckDB uses
read_json_auto()to detect the structure and flatten nested objects into columns. - Data is loaded into the
importedtable.
Example Queries
SELECT * FROM imported LIMIT 20;
SELECT count(*) FROM imported;
SUMMARIZE imported;
SELECT typeof(column_name) FROM imported LIMIT 1;
Tips
- DuckDB handles most CSV edge cases (quoted fields, mixed delimiters, etc.) automatically
- For JSON arrays, DuckDB flattens the top-level array into rows
- NDJSON (one JSON object per line) is the most efficient JSON format for large datasets
- If auto-detection gets a column type wrong, you can cast it in your query:
SELECT CAST(col AS INTEGER) FROM imported