Skip to content
UniKit

SQL to CSV

Turn INSERT statements back into a CSV table: multi-row VALUES, column lists, NULL, escaped strings and backtick, double-quote or bracket identifiers are all handled.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Conversion settings

Only INSERT statements are read: multi-row VALUES, column lists, NULL, escaped quotes, backtick, double-quote and bracket identifiers plus function calls; other statements are ignored.

CSV result

What this tool does

  • Turn the INSERT part of a database dump (mysqldump, pg_dump) back into CSV so you can check it in a spreadsheet or hand it to non-technical colleagues.
  • Recover rows that were deleted by mistake: paste the relevant INSERT statements and get a table you can re-import.
  • Compare two versions before a migration by converting both sets of INSERTs to CSV and diffing them line by line.
  • Convert SQL seed data into CSV fixtures so test authors get realistic input samples.

Example

Input

INSERT INTO users (id, name, active) VALUES (1, 'Ada', TRUE), (2, 'O''Brien', FALSE);

Output

id,name,active
1,Ada,TRUE
2,O'Brien,FALSE

Column names come from the INSERT column list; NULL is written as an empty cell by default and can be replaced with any placeholder.

Frequently asked questions

Which SQL forms are supported?

INSERT INTO table (columns…) VALUES (…), (…) with or without a column list. Literals may be strings, numbers, NULL, TRUE / FALSE, function calls such as NOW() and :: casts. Other statements (SELECT, CREATE TABLE, …) are skipped.

How are escaped strings decoded?

Both conventions are handled: doubled single quotes as in the SQL standard, and MySQL backslash escapes. If a decoded cell contains a comma, a double quote or a newline, the CSV output quotes it and doubles any inner quotes.

Do backticks or double quotes around table and column names matter?

No. Backticks (MySQL), double quotes (standard SQL, PostgreSQL, SQLite) and square brackets (SQL Server style) are all recognised as identifier quotes and stripped, so you get the real names.

What if several INSERT statements have different column lists?

Columns are the union of every statement column list in order of first appearance. A statement without a column list is aligned positionally and missing cells stay empty. A mismatch between the value count and the column list is reported with its line number.

Does the CSV include a BOM?

Not by default. Enable "Add a UTF-8 BOM" when the file contains non-ASCII text and you plan to open it in Excel, otherwise Excel may show mojibake.

Keywords:sql to csvinsert to csvextract datasql parsermysql dumppostgresqlSQL转CSV导出表格INSERT 解析数据提取

Related tools