SQL to CSV Converter

Sometimes the only copy of the data you need is a .sql file from a backup, a dump of INSERT INTO users (id, email, created_at) VALUES (...) statements. Loading it into a database just to export it again is slow. This converter reads the column list and each VALUES tuple straight from the INSERT syntax and emits a CSV you can open in Excel, Google Sheets, Numbers or pandas without ever restoring the schema.

How to convert SQL INSERTs to CSV

  1. 1

    Paste the SQL

    Drop in one or more INSERT statements. Both single-row and multi-row VALUES (...) blocks are supported.

  2. 2

    Columns auto-detected

    The parser reads the `(col1, col2, ...)` list right before VALUES and treats it as the CSV header row.

  3. 3

    Rows extracted

    Each `(val1, val2, ...)` tuple becomes a CSV row. Single-quoted strings are unquoted; numbers and NULLs pass through as text.

  4. 4

    Copy the CSV

    Grab the CSV output and paste it into a spreadsheet, or save it with a `.csv` extension.

What the parser accepts

INSERT INTO users (id, email, created_at) VALUES
  (1, 'alice@example.com', '2024-01-12 09:00:00'),
  (2, 'bob@example.com',   '2024-01-13 10:30:00'),
  (3, 'carol@example.com', '2024-01-13 11:15:00');

Becomes:

id,email,created_at
1,alice@example.com,2024-01-12 09:00:00
2,bob@example.com,2024-01-13 10:30:00
3,carol@example.com,2024-01-13 11:15:00

CSV escaping rules applied

  • The delimiter is always a comma; there is no separator option.
  • Fields containing commas, double quotes or newlines are wrapped in double quotes.
  • Internal double quotes are doubled (" becomes ""), per RFC 4180.
  • Leading and trailing single quotes from SQL string literals are stripped.
  • SQL NULL passes through as the literal text NULL; replace it downstream if your tooling expects empty cells.

Limitations to know

  • Column list required. The parser reads the header from the (col1, col2, ...) list before VALUES. A bare INSERT INTO t VALUES (...) without the column list produces CSV rows with no header.
  • One table at a time. If your dump mixes INSERTs for different tables, split them first. Rows of different widths produce a ragged CSV.
  • No CREATE TABLE parsing. Column types are not used. Dates, JSON and binary blobs come through as raw text.
  • Every parenthesis group becomes a row. The parser turns each (...) group into a row, so trailing clauses that contain parentheses (ON DUPLICATE KEY UPDATE, RETURNING), function calls like NOW(), or nested arrays like (1,2,3) inside a value add stray rows. Keep the input to plain INSERT ... VALUES tuples and replace such expressions with literals before pasting.

Frequently Asked Questions

Yes, as long as the INSERT follows the standard INSERT INTO table (cols) VALUES (...) form, which is shared across those databases. The tool does not run a full SQL parser: it extracts the column list and the parenthesised value tuples, so keep each statement to plain INSERT syntax.

Commas inside single-quoted SQL strings are preserved. On output, any field containing a comma, quote or newline is wrapped in double quotes and internal quotes are doubled, matching RFC 4180. Values that themselves contain parentheses may not split cleanly.

No. Your SQL is sent to our server, parsed in one pass and returned, so keep the input to a few megabytes at a time. For very large dumps, split the file into chunks (one INSERT block per chunk) and convert them in pieces.

No, the output is a flat CSV. Column types, indexes and constraints live in CREATE TABLE and are outside the scope of this converter.

Your SQL is sent to our server only to produce the CSV and is not stored; we keep an anonymous count of how many rows were converted, never the SQL text itself.

Related Tools

Tool available in other languages