csvjson

SQL INSERT to CSV

Paste INSERT INTO statements from a database dump, migration file, or seed script. Column headers come from the INSERT column list. NULL becomes empty. Download as CSV in one click.

How it works

Column names from the INSERT list

INSERT INTO table (col1, col2) VALUES ... — the parenthesized column list becomes the CSV header row. Backtick and double-quote identifiers are unquoted automatically.

NULL → empty field

SQL NULL becomes an empty CSV cell — the standard representation for missing data. TRUE and FALSE are preserved as literal strings. Numbers and dates stay as-is.

Multi-row and multi-statement

Handles both multi-row INSERT ... VALUES (r1), (r2), (r3); style and multiple separate INSERT statements in one paste. All rows are combined into a single CSV output.

String escaping handled

Single-quoted strings with '' and \' escape sequences are parsed correctly. The unescaped string value appears in the CSV.

When to use this

1

Reading a database dump without a database

pg_dump and mysqldump output INSERT statements. Paste them here to read the data without spinning up a database instance.

2

Analyzing a SQL migration file

Seed data and test fixtures in SQL migration files are INSERT statements. Convert them to CSV to inspect, sort, and validate the data in a spreadsheet before running the migration.

3

Extracting rows from a SQL backup

When you only need a few tables from a large backup file, copy the relevant INSERT blocks and convert just those rows to CSV.

4

Sharing data without database access

Send CSV to a colleague who doesn't have database access. They can open it in Excel or Google Sheets without any SQL knowledge.

Example

pg_dump excerpt — NULL email field becomes an empty CSV cell

Input (SQL)
INSERT INTO users (id, name, email, plan) VALUES
(1, 'Alice Chen', 'alice@example.com', 'pro'),
(2, 'Bob Kumar', 'bob@example.com', 'free'),
(3, 'Sara Mills', NULL, 'enterprise');
Output (CSV)
id,name,email,plan
1,Alice Chen,alice@example.com,pro
2,Bob Kumar,bob@example.com,free
3,Sara Mills,,enterprise

Sara Mills has NULL for email — it becomes an empty field between two commas. Column names come from the INSERT column list.

Frequently asked questions

Does this work with mysqldump and pg_dump output?

Yes. Both tools produce standard INSERT INTO ... VALUES statements. Copy the INSERT blocks for the tables you want and paste them here. You don't need to paste the full dump file — just the INSERT statements.

What if there's no column list in the INSERT statement?

INSERT INTO table VALUES (...) without a column list produces placeholder headers: column1, column2, etc. You can rename them in Excel or Google Sheets after opening the CSV.

Does it handle multi-row INSERT statements like (r1), (r2), (r3)?

Yes. The multi-row INSERT syntax (common in MySQL exports) is fully supported. Each value group in parentheses becomes one CSV row.

My strings contain single quotes. Will that break the parser?

No. Both '' (SQL standard escape) and \' (MySQL escape) are handled. The converted string in the CSV has the literal single quote without any escape sequence.

Can I convert the CSV back to SQL INSERT statements?

Yes. Use the CSV to SQL converter on this site. It handles type inference, NULL detection, and lets you configure the table name and batch size.