CSV Query as SQL

Run SQL SELECT queries against an uploaded CSV in the browser.

CSV Query as SQL loads a CSV into an in-memory table and lets you query it with a SELECT statement. Paste or upload a file, name the table, run the query and export the result as CSV or JSON. It is a quick way to filter, sort and summarise a spreadsheet export without a database.

What does it mean to query a CSV with SQL?

A CSV file is plain text where each line is a row and commas separate the fields; the first line usually holds column names. SQL is the standard language for asking questions of tables, such as which rows match a condition, how to sort them or how to group and total them. Querying a CSV with SQL means treating the file as a table: the header gives the column names and each line becomes a row. This tool parses the CSV in the page, converting numeric-looking values to numbers, and exposes the rows as a table you name. Queries run with AlaSQL, a JavaScript SQL engine that is similar to common SQL but not identical to SQLite or PostgreSQL. To keep it safe, only a single SELECT or WITH query is accepted, and function names must be on an allowlist.

How to use CSV Query as SQL

  1. Provide the CSV Paste into the CSV box or use Upload a CSV file. The box is pre-filled with a small sample of names, ages and cities.
  2. Name the table Set Table name, which defaults to data. Use that name after FROM in your query.
  3. Write the query Enter a SELECT or WITH query in SQL query. Column names are the CSV header names.
  4. Run query Click Run query. The result grid and a row count appear below.
  5. Export Pick CSV or JSON under Export format, then use Copy results or Download results (query-results.csv or query-results.json).

Frequently asked questions

Is my CSV uploaded?

No. The file is read and queried in your browser with AlaSQL; the data stays in the page and is not sent anywhere.

Which SQL dialect does it use?

AlaSQL, a JavaScript SQL engine. It handles common SELECT features such as WHERE, GROUP BY, ORDER BY, joins and WITH, but some behaviour differs from SQLite or PostgreSQL. Test unusual syntax on a small sample.

Why is my function refused?

For safety the tool accepts only an allowlist of function names. Unknown names are rejected instead of being resolved as JavaScript, which is also why words like INTO, EVAL or CREATE are blocked.

Can I query two CSV files together?

No. Each run exposes one table built from the CSV in the box, so you cannot join to a second file.

Why are my numbers or dates treated oddly?

Values that look like numbers become numbers and true or false become booleans; everything else stays text, including dates. Compare dates as ISO strings or use the date helpers.

What are the size limits?

5 MB of CSV text, 100,000 data rows, and 1,000 displayed result rows. Exports contain all result rows, up to 100,000.