sqlstreak

Query a CSV file with SQL online

Drop a CSV file and it becomes a table you can query with real PostgreSQL or SQLite. Types detected, starter queries written for you.

Your file never leaves this browser

Everything runs locally: the database engine is downloaded once, then your file is read on this device. Nothing is uploaded.

Lesson · Counting things

Practise this in 5 minutes

Grouping and counting rows is the most useful thing you can do with a CSV. Our lesson GROUP BY walks you through it step by step on a real database, with instant feedback.

Start the lesson

Get the sqlstreak newsletter

Short SQL tips you can use the same day, plus a heads-up when we ship new free tools and lessons. It lands now and then, not every other morning.

No spam, unsubscribe in one click.

How to run SQL on a CSV file

  1. Drop your CSV on the box above, or choose it from your computer. The first line should hold the column names.
  2. Check the columns. Each header becomes a lowercase column name (Order Date becomes order_date) and gets a type: number, date or text.
  3. Write a query or click one of the suggested ones, then press Run or Ctrl/⌘ + Enter.
  4. Export the result as a new CSV file when it looks right.

Private by design

Most "CSV to SQL" sites upload your file to their server. This one can't: the database engine runs inside your browser tab as WebAssembly, so the file is read on your device and the table lives in your tab's memory. Close the tab and it's gone. That makes it safe for customer lists, finance exports and anything else you shouldn't paste into a random website.

Queries to start with

Five patterns cover most questions you'll ask of a spreadsheet export:

Stuck on a query? Paste it into the SQL formatter and explainer to see what each part does.

Frequently asked questions

Is my CSV file uploaded anywhere?
No. The file is read and turned into a table inside your browser tab, by a database engine compiled to WebAssembly. It never leaves your computer, and closing the tab deletes it. You can even disconnect from the internet after the page loads.
How big can the CSV be?
Up to 25 MB and the first 200,000 rows, with up to 100 columns. Bigger files would make the browser tab struggle. Most exports from spreadsheets and BI tools fit easily.
How are column types detected?
Every value in a column is checked. Whole numbers become INTEGER, other numbers NUMERIC (REAL in SQLite), YYYY-MM-DD values DATE, values with a time TIMESTAMP, and everything else TEXT. Numbers with leading zeros, like zip codes, stay text so the zeros aren't lost. Empty cells become NULL.
Can I join two CSV files?
Yes. Add a second file and it becomes another table next to the first, so you can JOIN them, UNION them or compare them with a subquery.
PostgreSQL or SQLite?
Both are real engines: PGlite is PostgreSQL compiled to WebAssembly, and SQLite runs as WebAssembly too. Pick the one you use at work. Switching reloads your files into the other engine.
Can I use an Excel file?
Save it as CSV first (File → Save As → CSV in Excel, or File → Download → CSV in Google Sheets), then drop that file here. Semicolon- and tab-separated files work too.