ToolLineup

SQL to CSV Converter

This SQL to CSV converter reads the rows out of INSERT … VALUES statements and writes them as CSV you can open in any spreadsheet. The statements are properly tokenised, so a comma inside a string literal stays part of the value instead of splitting the row, and an escaped apostrophe is unescaped back to the character it stands for. Several INSERTs into the same table are merged into one table, and NULL becomes an empty cell rather than the literal text NULL. When a dump contains several tables you can step through them by number, and everything runs in your browser.

How it works

Reads the rows out of INSERT … VALUES statements. The column list in the statement becomes the header, and several INSERTs into the same table are merged into one result — so a dump split across many statements still gives you one table.

Quoted strings are unescaped properly, so a value written as 'O''Brien' comes back as O'Brien, and NULL becomes an empty cell rather than the literal text.

The conversion runs entirely in your browser — nothing you paste or upload is sent to a server.

SQL input
Paste INSERT statements or upload a .sql dump…
CSV output

How to convert SQL to CSV

  1. Paste your INSERT statements into the input on the left, or upload a .sql dump.
  2. Choose the delimiter your spreadsheet expects — comma, semicolon, tab or pipe.
  3. Copy the CSV, or download it and open it in a spreadsheet.

Getting a dump into a spreadsheet

The usual route is to restore the dump into a scratch database and export from there, which needs a running server and a fair amount of patience. When all you want is to look at the data, reading the rows straight out of the INSERT statements is faster and leaves no trace behind.

Two escaping layers, handled in the right order

SQL and CSV both escape quotes, and they do it differently. A value stored in SQL as 'O''Brien' is unescaped to O'Brien first, and only then re-escaped for CSV — which in this case needs no quoting at all, since a single quote is not special in CSV. Doing it in the wrong order leaves doubled apostrophes scattered through the spreadsheet.

NULL becomes an empty cell

Writing the literal text NULL would be indistinguishable from a genuine string value of "NULL", which is a real value in plenty of datasets. An empty cell is the honest representation, and it is what spreadsheets and import tools expect a missing value to look like.

Several tables in one dump

A dump usually covers many tables. Each is collected separately, statements against the same table are merged, and the note under the output tells you how many were found so you can step through them.

Common use cases

  • Reviewing what a dump actually contains before restoring it.
  • Sending a table to someone who works in a spreadsheet, not a SQL client.
  • Diffing two dumps by loading both into adjacent sheets.

Frequently asked questions

How do I convert SQL to CSV?

Paste your INSERT statements into the left panel or upload a .sql file. The CSV appears on the right, ready to download and open in a spreadsheet.

Does a comma inside a value break the output?

No. The SQL is tokenised before anything is split, so a comma inside a string literal stays part of that value. The CSV writer then quotes the field, which keeps it in one column.

What happens to NULL?

It becomes an empty cell. Writing the four letters NULL would be indistinguishable from a genuine string value of "NULL", so an empty cell is the safer representation.

Can I use a semicolon separator?

Yes. Choose it from the delimiter dropdown, which is what spreadsheets in locales using the comma as a decimal mark expect.

What if my dump has more than one table?

They are collected separately and the note under the output says how many were found. Step through them with the table number box.

Is my data uploaded?

No. Parsing happens in your browser and nothing you paste or open is transmitted.

Related tools