SQL to CSV Converter

Extract data from SQL INSERT INTO statements and export as CSV with customizable delimiters and formatting options.

About This Tool

The SQL to CSV converter is a free browser-based tool that extracts tabular data from SQL INSERT INTO statements and outputs it as CSV. If your SQL includes CREATE TABLE statements, the tool uses them to determine column names and ordering; otherwise it reads the explicit column list from the INSERT statement itself. This makes it easy to turn database dump files, migration scripts, or seed data into spreadsheet-friendly formats without installing any software.

The converter supports multi-row INSERT syntax (INSERT INTO ... VALUES (...), (...), (...)), multiple separate INSERT statements for the same table, and SQL with mixed CREATE TABLE and INSERT statements. Values are properly unescaped — single-quote escaping, backslash sequences, and NULL literals are all handled. You can customize the output delimiter (comma, tab, pipe, or semicolon), choose between double or single quote characters for CSV field quoting, toggle the header row on or off, and decide how NULL values are represented in the output.

If you need to go the other direction — converting JSON data to SQL INSERT statements — check out the JSON to SQL INSERT tool. For converting between CSV and JSON, try the CSV ↔ JSON Converter. And if you want to clean up your SQL before extracting data, the SQL Formatter can help.

All processing runs entirely in your browser. Your SQL statements are never sent to any server, making this tool safe to use with production data, proprietary schemas, and sensitive information.

How to Use

  1. Paste your SQL into the SQL Input panel. Include CREATE TABLE statements for column names, or just INSERT INTO statements with explicit column lists.
  2. Select your preferred Delimiter (comma, tab, pipe, or semicolon) from the dropdown.
  3. Choose a Quote character (double or single) for CSV field quoting.
  4. Set the NULL as option to control how SQL NULL values appear in the output (empty string, "NULL", "null", or "N/A").
  5. Toggle Header Row to include or exclude column names as the first CSV row.
  6. Click Preview to see the extracted data in a table view below the panels.
  7. Click Copy or press Ctrl+Shift+C to copy the CSV to your clipboard, or click Download to save it as a .csv file.

Popular SQL to CSV Examples

View all SQL to CSV examples →

FAQ

What SQL syntax is supported?

The tool supports standard SQL INSERT INTO ... VALUES syntax, including multi-row inserts with multiple value tuples in a single statement. It also parses CREATE TABLE statements to extract column names and order. SQL comments (-- and /* */) are stripped automatically. Both quoted and unquoted identifiers are handled.

Do I need CREATE TABLE statements?

No. If your INSERT INTO statements include an explicit column list (e.g., INSERT INTO users (id, name, email) VALUES ...), the tool uses those column names. CREATE TABLE is only needed when the INSERT statement omits the column list. If neither is available, generic column names (column_1, column_2, etc.) are generated.

How are NULL values handled?

SQL NULL values are converted based on your NULL representation setting. By default they become empty strings in the CSV. You can also choose to output them as 'NULL', 'null', or 'N/A'. The setting applies to all NULL values in the output.

Can I convert multiple tables at once?

The tool processes all INSERT INTO statements in your input. If they target the same table, all rows are merged into one CSV. If they target different tables, the rows from all tables are combined and the column set is the union of all columns. For best results, convert one table at a time.

How are special characters in values handled?

SQL string escaping is handled automatically. Doubled single quotes ('') are converted to single quotes, backslash escape sequences (\n, \t, \\) are interpreted, and the resulting values are properly quoted in the CSV output according to RFC 4180 rules when they contain the delimiter, quote character, or newlines.

Is my data safe?

Yes. All parsing and CSV generation runs entirely in your browser using JavaScript. No data is sent to any server. You can verify this by checking the Network tab in your browser's developer tools while using the tool.

What is the maximum input size?

There is no hard limit, but very large inputs (tens of thousands of rows) may cause the browser to slow down. The preview table is capped at 100 rows for performance, though the full CSV output and download include all rows.

Related Tools