b2KIT

SQL INSERT to CSV Converter

Convert SQL INSERT statements to CSV format for data migration and spreadsheet import workflows.

Tested tool guide Tested browser tools Checked August 16, 2026

What SQL INSERT to CSV Converter does, with a checked example

Paste one or more INSERT statements and this tool turns them into a CSV file: the column list after the table name becomes the header row, and each VALUES tuple becomes one data row. It handles several statements pasted at once, multi-row VALUES lists, and standard SQL string escaping. The thing most users get wrong: it converts INSERTs only. CREATE TABLE definitions, SELECT queries, and UPDATE statements in the same paste are ignored or rejected, so pasting a full database dump wholesale produces a CSV missing everything that was not an INSERT. The paste is processed entirely in the browser; nothing is uploaded.

Worked example

A concrete input and expected output from the current implementation.

Input

INSERT INTO products (id, name, price) VALUES (1, 'Wireless Mouse', 24.99);
INSERT INTO products (id, name, price) VALUES (2, 'Mechanical Keyboard', 89.50);

Expected output

id,name,price
1,Wireless Mouse,24.99
2,Mechanical Keyboard,89.50

The column list after the table name becomes the header row, and each VALUES tuple becomes one data row in column order. Quoted strings lose their quotes, and numeric literals pass through unchanged, so 24.99 and 89.50 appear exactly as written.

How the result is produced

1

Reading the statement structure

The converter looks for INSERT INTO statements followed by a parenthesized column list, then a VALUES clause. Column names become the CSV header row in the order they were written. Each parenthesized value group after VALUES becomes one data row, with values placed under their matching columns. Extra whitespace, line breaks, and trailing semicolons between statements are tolerated, and output rows follow the order of the input statements.

2

How values are copied

Each value is taken out of the SQL as its literal text: surrounding quotes are removed from strings, a doubled quote inside a string is reduced to one, and numbers, NULL, and date literals pass through as written. The converter does not reinterpret values, so the CSV reflects the SQL exactly; any type conversion or date-format normalization is left to the spreadsheet or database that consumes the CSV.

Good uses

  • Recovering table data from a backup or export made of INSERT statements and loading it into a spreadsheet for review, deduplication, or cleanup.
  • Turning INSERT statements copied from seed scripts, ORM logs, or documentation into CSV fixture files for tests or for import into another database.
  • Building a CSV upload when the only access to the data is a file of INSERTs from a database you cannot query directly.

Limits and checks

  • Non-INSERT content is not converted. CREATE TABLE, index definitions, comments, and other statements in the same paste contribute nothing to the output, so a standard database dump needs its INSERTs isolated or re-exported first.
  • Values are copied, not interpreted: a string that looks like a number stays a string, and NULL or date literals appear exactly as written. Columns often need type and format fixes after import.
  • INSERTs written without a column list, such as INSERT INTO t VALUES (1, 'x'), give the tool nothing to build a header from and cannot produce a column-named CSV. Re-export with column names included, for example mysqldump --complete-insert or pg_dump --column-inserts.

Common questions

Will this convert an entire SQL dump file?

Only the INSERT statements within it. CREATE TABLE, schema comments, SET lines, and other statements are not converted, so a default mysqldump or pg_dump output yields an incomplete CSV. Regenerate the dump with column-inserts mode (mysqldump --complete-insert, pg_dump --column-inserts) or export CSV directly from the database, then compare the source row count with the CSV.

How are strings that contain commas or quotes handled?

The CSV output uses the standard convention: a value containing a comma, quote, or line break is wrapped in double quotes with embedded quotes doubled, so spreadsheets open it as a single cell. SQL's doubled single quotes are collapsed first. If a spreadsheet shows wrong column counts, check its delimiter and quoting settings before blaming the file.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools