← 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

  1. Open the DuckDB Browser.
  2. Drop your .csv file onto the drop zone.
  3. DuckDB auto-detects the delimiter, header row, and column types using read_csv_auto().
  4. Data is loaded into the imported table.

Loading JSON Files

  1. Drop your .json, .jsonl, or .ndjson file onto the drop zone.
  2. DuckDB uses read_json_auto() to detect the structure and flatten nested objects into columns.
  3. Data is loaded into the imported table.

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