SQL to CSV
Extract INSERT statement rows from SQL into CSV.
SQL to CSV Converter Online
The SQL to CSV converter extracts the rows from INSERT INTO … VALUES statements and writes them as a CSV file. It is the quickest way to get data out of a database dump when you do not have — or do not want to spin up — a database server: paste the dump, check the preview, and download a file that opens in Excel, Google Sheets, or any data tool.
What the parser understands
The converter tokenises SQL rather than using fragile regular expressions, so commas and parentheses inside quoted strings, escaped quotes ('' and '), comments, and multi-row VALUES lists are all handled. It reads MySQL/MariaDB dumps with backtick identifiers, PostgreSQL and SQLite with double-quoted names, and SQL Server with square brackets. INSERT IGNORE, REPLACE INTO, and INSERT OR REPLACE are treated like normal inserts. Other statements — SELECT, UPDATE, SET, locking commands — are skipped.
Options
- Delimiter – comma, semicolon, tab, or pipe.
- Table number – which table to export when the script inserts into more than one.
- Include header row – write the column names as the first line, or data only.
Merging multiple INSERTs
Dumps usually split large tables into many INSERT statements. All inserts into the same table are merged into one CSV, and if later statements list additional columns, those columns are added and earlier rows get empty values for them.
Edge cases
Numbers are written without trailing zeros (89.00 becomes 89), NULL becomes an empty field, and SQL string escapes are decoded, so '27'' Monitor' appears as 27' Monitor. If no INSERT statements are found you get a clear error instead of an empty file.
Related tools
Prefer structured output? Use SQL to JSON or SQL to XML. To browse a dump first, open it in the SQL Viewer. Going the other direction, CSV to SQL generates INSERT statements, and the CSV Viewer displays the result as a table.
Frequently Asked Questions
My dump inserts into several tables. Which one is exported?
CSV holds a single table, so the converter exports one table at a time. Tables are numbered in the order they first appear in the script; set “Table number” to 2, 3, and so on to export the others. A number larger than the table count selects the last table.
What happens to NULL values?
SQL NULL becomes an empty field in the CSV. Quoted empty strings ('') are also written as empty fields, since CSV has no way to tell the two apart.
Where do the column names come from?
From the column list of the INSERT statement, e.g. INSERT INTO users (id, name) VALUES …. When an INSERT has no column list, the names are taken from a matching CREATE TABLE earlier in the script, or generated as column1, column2, and so on.
Is the CSV compatible with Excel?
Yes. Fields that contain the delimiter, quotes, or line breaks are quoted according to RFC 4180. For Excel in locales that use a decimal comma, choose the semicolon delimiter.