SQL to CSV

Convert an SQL dump (INSERTs) into a CSV file.

About SQL to CSV

A database dump is full of INSERT statements that are useless outside a database server, yet the data inside them is exactly what you need in a spreadsheet. This tool scans the SQL text for INSERT INTO ... VALUES (...) statements, takes the column list of the first one as the header and writes one CSV row per statement, removing the SQL quoting.

Paste the SQL, name the file and download the CSV. The extraction uses a regular expression in your browser, so a dump containing customer records never leaves your machine.

How to use SQL to CSV step by step

  1. Paste the SQL dump or the list of INSERT statements into the text area.
  2. Type the name of the CSV file (sql-export by default).
  3. Click "Convert and download CSV". Values in single quotes are unquoted and doubled quotes ('') are restored to a single quote.

Input and output example

Input

INSERT INTO `users` (`id`, `name`, `city`) VALUES (1, 'Ana', 'Madrid');
INSERT INTO `users` (`id`, `name`, `city`) VALUES (2, 'Luis', 'Sevilla');

Output

id,name,city
1,Ana,Madrid
2,Luis,Sevilla

Why use our SQL to CSV?

Common use cases

Limits and tips

Frequently asked questions

Which SQL dialects are supported?

Any dump whose INSERTs list the columns explicitly and insert one row per statement: MySQL and MariaDB (with or without backticks), PostgreSQL, SQLite and SQL Server in most cases. Bulk inserts with several value groups in one statement or INSERT ... SELECT are not converted.

Why is my CSV empty?

No statement matched the expected pattern. Check that each INSERT has a column list in parentheses, the keyword VALUES, one set of values in parentheses and a semicolon at the end. Dumps created with extended inserts (one INSERT with many rows) must be re-exported with one row per statement.

What is the difference between a SQL dump and a CSV?

A SQL dump is a script of statements that recreates tables and rows inside a database engine; it carries schema and typing but is not readable by spreadsheets. CSV holds only the values in a delimited table that any spreadsheet or scripting language can open, without the schema.

Can I convert several tables at once?

The header is taken from the first INSERT, so mixing tables produces rows with mismatched columns. Paste the statements of one table at a time for a clean result, or filter the dump by table name first.

Is the dump uploaded?

No. The regular expression runs in your browser and the CSV is generated locally. The tool is safe for dumps with personal or confidential data.

Related guides

Related tools

Other free utilities you may find useful

Available languages