Skip to content
ZeroServer.tools

SQL to CSV Converter

Convert SQL INSERT statements into CSV rows, right in your browser.

or drop a file here
CSV Output (3 rows)

How SQL to CSV conversion works

Paste one or more INSERT INTO table (...) VALUES (...) statements and this tool extracts the column names and every value tuple into a clean CSV table. It handles multiple rows per statement, multiple statements at once, single- and double-quoted strings (including '' and \' escaped quotes), numbers, booleans, and NULL (converted to an empty cell). If a statement omits its column list, generic column_1, column_2… headers are used instead. Output fields are quoted per RFC 4180 whenever they contain a comma, quote, or newline. Everything runs locally in your browser — your SQL and data are never uploaded anywhere.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Recovering tabular data from a dump file when you have INSERT statements and no database.
  • Extracting seed data out of a migration to inspect it in a spreadsheet.
  • Turning a colleague's INSERT block into rows you can review.
  • Getting data out of a schema dump without standing up a server.
  • Producing a CSV from statements generated by another tool.

Frequently Asked Questions

What does it parse out of an INSERT statement?
The column list, if declared, and each parenthesised value tuple. The split respects nesting and quoting, so a comma inside a string literal or inside a nested function call does not break the tuple boundary — which a naive split on `),(` does immediately.
How is NULL represented in the CSV?
As an empty field, which is the closest CSV has to a null — the format has no type system and no way to distinguish an empty string from a missing value. That ambiguity is inherent, and it is why a loader importing the result needs to be told which one it should mean.
What happens to a quoted string containing a comma?
It is re-quoted for CSV: the field is wrapped in double quotes and any internal quote is doubled, per RFC 4180. SQL's single-quote escaping (`''`) and CSV's double-quote escaping are different conventions, so a value has to be decoded from one and re-encoded into the other.
Can it handle several INSERT statements?
Yes, as long as they target the same shape. Statements with different column lists cannot be merged into one CSV without inventing empty columns, which would silently change the data — so a mixed dump is better converted one table at a time.
Why not just use the database's own export?
You should, when you have access to it — `COPY TO CSV` in Postgres or `SELECT INTO OUTFILE` in MySQL are exact and handle types properly. This is for the case where all you have is a dump file, which is common when the data arrives from someone else.

Common errors and gotchas

  • Assuming the column order is stated. Statements that omit the column list depend on the table definition you may not have.
  • Mishandling escaped quotes inside string values, which a naive split breaks on.
  • Treating SQL `NULL` as the string 'NULL', which changes the meaning of every empty cell.
  • Overlooking multi-row INSERT syntax, where one statement carries many tuples.
  • Losing type information, since CSV has none and every consumer guesses again.

Related Converters tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate