SQL to CSV
Paste CREATE TABLE / INSERT INTO statements
Upload Your SQL Files
Drag & drop .sql files here or click to browse
Supports SQL and TXT formats · Max 10 files · 20 MB each
Your Converted CSV Files
Why Use This SQL to CSV Converter
Most SQL to CSV tools only handle basic INSERT INTO statements. This one actually runs your SQL against a real database engine, so it works with more real-world SQL — and it fixes formatting mistakes that other converters silently make.
- Paste SQL or upload files — Paste
INSERTstatements directly, or upload up to 10.sql/.txtfiles at once (20 MB per file, 200 MB per session) - Works with CREATE TABLE + INSERT dumps — the classic database export format
- Also works with plain SELECT and WITH (CTE) queries — no CREATE TABLE required; if your SQL is just a report query, it exports the result set directly
- Multiple tables? Multiple queries? No problem — if your SQL creates more than one table, the converter exports the first one and tells you the names of the others so you can pick a different one. If it finds several
SELECTstatements, it converts the last one and lets you know - Accurate decimals and booleans — columns declared as
DECIMAL(p,s)orNUMERIC(p,s)keep their exact decimal places (e.g.,75000.00instead of75000), andBOOLEANcolumns are written astrue/falseinstead of a confusing1/0 - Custom output options — choose your delimiter (comma, tab, space, or custom), include/exclude headers, and set the output encoding
- Live preview with search — review your CSV in a built-in viewer with search-and-highlight before downloading
- Multiple download formats — download as
.csvor.txt, or batch-download all converted files as a.zip - Privacy-first — uploaded files and converted output are automatically deleted after 1 hour, and your session is cleared every time you reload the page
How to Convert SQL to CSV
- Add your SQL — Paste your SQL statements into the text box, or switch to the upload tab and drag in your
.sql/.txtfile(s) - Set your options (optional) — Choose a specific table name (or leave it on "auto" to use the first table found), pick a delimiter, toggle headers on/off, and set an encoding if needed
- Click "Convert to CSV" — The tool parses your SQL, builds the table(s) in a secure sandboxed environment, and generates your CSV in seconds
- Review and download — Preview the result, search within it if needed, then download as CSV/TXT or copy it straight to your clipboard
Example: Convert a SQL INSERT Dump to CSV
Here's a typical SQL export — a CREATE TABLE statement followed by INSERT INTO rows:
sql
CREATE TABLE employees (
id INTEGER,
name TEXT,
department TEXT,
salary DECIMAL(10,2),
is_active BOOLEAN
);
INSERT INTO employees VALUES (1, 'Sarah Chen', 'Engineering', 95000, 1);
INSERT INTO employees VALUES (2, 'Miguel Torres', 'Sales', 72000.5, 1);
INSERT INTO employees VALUES (3, 'Priya Patel', 'Engineering', 88000, 0);
Converted output:
csv
id,name,department,salary,is_active
1,Sarah Chen,Engineering,95000.00,true
2,Miguel Torres,Sales,72000.50,true
3,Priya Patel,Engineering,88000.00,false
Notice the salary column keeps two decimal places because it was declared DECIMAL(10,2), and is_active shows as true/false instead of 1/0. Most SQL to CSV converters get this wrong — they either drop the trailing zero or leave booleans as raw integers, which can break spreadsheet formulas and data imports downstream.
Example: Convert a SQL SELECT Query to CSV
You don't need a full database dump. A plain query works too:
sql
SELECT name, department, salary
FROM employees
WHERE department = 'Engineering'
ORDER BY salary DESC;
This converts directly to a CSV of the query's result set — useful for exporting filtered reports without needing the full table structure.
Common Use Cases
- Database migration — Export tables from a SQL dump into CSV for import into another system, spreadsheet, or database
- Reporting — Turn a
SELECTquery's results into a shareable CSV report without opening a database client - Spreadsheet analysis — Move SQL data into Excel or Google Sheets for pivot tables and charts
- Backups and archiving — Store a portable, human-readable copy of table data
- Testing and QA — Quickly generate CSV test data or sample datasets from SQL fixtures
- Data cleanup before re-import — Convert, edit in a spreadsheet, then convert back to SQL
Troubleshooting & Tips
"No CREATE TABLE, INSERT INTO, or SELECT statement found" Your SQL needs at least one of these three statement types. Pure UPDATE, DELETE, DROP, or ALTER statements have nothing to export — add a CREATE TABLE + INSERT pair, or a SELECT query.
"This SQL contains restricted statements" For security, statements like ATTACH, DETACH, PRAGMA, LOAD_EXTENSION, and BACKUP are blocked, since they can reach outside the isolated conversion environment. Remove these lines and convert again — they don't affect table or query data.
My file has multiple tables, but only one converted That's expected — the converter exports one table at a time. Check the notification after conversion; it lists the other table names found. Enter that table name in the "Table Name" field and convert again to export a different one.
My SQL has multiple SELECT queries Only the last SELECT (or WITH) statement in your script is exported. If you want a different query's results, trim your SQL down to just that query.
Large files or timeouts Files are capped at 20 MB each (200 MB total per session), and conversions that take too long are automatically stopped. If a file times out, try splitting it into smaller chunks or removing unnecessary data.
MySQL/PostgreSQL dump syntax The converter runs your SQL against a standard SQL engine. Plain CREATE TABLE and INSERT INTO statements work reliably across dialects. Dumps with engine-specific extras (ENGINE=InnoDB, AUTO_INCREMENT, unsigned, etc.) may need minor cleanup first — remove dialect-specific clauses and keep the core column definitions and INSERT rows.
Frequently Asked Questions
Is this SQL to CSV converter free?
Yes, it's completely free to use with no signup required.
Does my SQL data get stored?
No. Uploaded and converted files are automatically deleted after one hour, and your session is cleared every time you reload the page.
What file types can I upload?
.sql and .txt files, up to 20 MB per file and 10 files (200 MB total) per session.
Can I convert a SQL SELECT query without a CREATE TABLE?
Yes. If your SQL doesn't create a table, the converter runs the last SELECT or WITH query and exports its result set directly.
What if my SQL creates more than one table?
The converter exports the first table by default and shows you the names of the other tables found. Enter a specific table name in the options to export a different one.
Does it support custom delimiters?
Yes — choose comma (default), tab, space, or a custom character.
How are NULL values handled?
NULL values are written as empty fields in the CSV output.
Does it fix decimal and boolean formatting?
Yes. Columns declared as DECIMAL/NUMERIC keep their exact decimal precision, and BOOLEAN columns are converted to true/false instead of raw 1/0 — a common source of errors in other converters.
Can I convert multiple SQL files at once?
Yes, upload up to 10 files and convert them in one batch, then download them individually or as a single ZIP.
Can I download as a format other than CSV?
Yes, you can download the result as .csv or .txt.