DevToolsmith

SQL to CSV

Turn SQL INSERT statements into a CSV file with headers. Select the source dialect and table, check the output, and download it without uploading a dump or connecting to a database.

Runs 100% in your browser — nothing is uploaded

SQL INSERT statements
Tip: drop a file here209 chars · 209 bytes · 4 lines
CSV
100 chars · 100 bytes · 4 lines

3 rows · 4 columns in users. Literal VALUES only; SQL is never executed. Strings starting with formula characters are prefixed with an apostrophe.

Extract rows from SQL text

Copy INSERT statements that contain explicit column lists and literal VALUES. Multiple tuples and repeated INSERT statements are combined for each table. Strings, numeric literals, booleans and NULL are supported; SQL functions and expressions stop conversion with an error.

SQL input
INSERT INTO people (id, name, note) VALUES
(1, 'Ada', 'London, UK'),
(2, 'Grace', 'She said "hello"');
CSV output
id,name,note
1,Ada,"London, UK"
2,Grace,"She said ""hello"""

Keep IDs exact when opening a spreadsheet

The conversion preserves number text, but Excel can round identifiers longer than 15 digits when opening CSV. Import ID columns as text, or convert through SQL to JSON and create an XLSX file with the Excel converter, which stores long IDs as text.

Export limitations

A CSV cell has no SQL type. NULL and an empty string both produce an empty cell, and date literals become text. Conversion is limited to 10 MB and 100,000 rows. Remove CREATE TABLE, transaction wrappers and conflict clauses before converting; they are not silently ignored.

Inspect the result with the CSV viewer, or go back with CSV to SQL.

Frequently asked questions

Which table is exported?

The selected table. Statements targeting the same qualified table are combined, while other tables appear in the selector. CSV headers include all columns encountered for the selected table.

How are commas, quotes and line breaks handled?

CSV uses double-quoted fields when necessary, doubles embedded double quotes, and preserves line breaks inside quoted fields. The output uses CRLF row endings.

What does formula protection change?

It prefixes cells beginning with formula characters such as =, +, - or @ with an apostrophe so spreadsheet applications treat them as text. Turn it off for a raw machine-readable export. This protection can also add an apostrophe to negative values.

Can CSV distinguish NULL from an empty string?

Not reliably. SQL NULL, absent columns and empty strings all become empty CSV cells. Use SQL to JSON when those distinctions matter.