SQL to CSV Converter – Export Table Data Online Free

Convert SQL INSERT statements to CSV instantly. Paste your SQL dump, download a clean CSV for Excel or Sheets. Free, browser-based, nothing uploaded.

SQL
97 chars · 1 lines · 97 bytes
CSV

Quick example: SQL INSERT → CSV

Paste a SQL INSERT statement like this:

INSERT INTO employees (id, name, department) VALUES
(1, 'Alice', 'Engineering'),
(2, 'Bob', 'Marketing');

…and get clean CSV output instantly:

id,name,department
1,Alice,Engineering
2,Bob,Marketing

How to use it: paste your SQL above, click Convert, then copy or download the result. The tool handles quoted string fields, strips SQL syntax, and auto-detects numbers so they don't get wrapped in extra quotes. Everything runs entirely in your browser — your data is never uploaded anywhere.

Turn SQL Data into a Spreadsheet-Ready CSV in Seconds

Copy a block of SQL INSERT statements or a CREATE TABLE dump, paste it into the converter above, and you get a clean CSV file (comma-separated values) you can open straight in Excel, Google Sheets, or any data tool. No installs, no sign-up, no waiting.

This is the fastest way to move data out of a database export — whether you got a .sql dump from MySQL, PostgreSQL, or SQLite — and into a format your teammates, clients, or BI tools can actually read.

How to Convert SQL to CSV

  1. Paste your SQL into the input box above. This works with INSERT INTO statements, full table dumps, or just the data rows.
  2. Click Convert. The engine parses the SQL and builds the CSV automatically.
  3. Copy or Download the result. One click copies to your clipboard; another saves it as a .csv file.

That's it. No configuration needed for standard SQL dumps.

Worked Example: MySQL Dump to CSV

Say you export a small table from MySQL and get this in your .sql file:

INSERT INTO orders (order_id, customer, total) VALUES
(101, 'Jane Smith', 49.99),
(102, 'Raj Patel', 129.00),
(103, 'Marie Curie', 19.50);

After converting, your CSV looks like this:

order_id,customer,total
101,Jane Smith,49.99
102,Raj Patel,129.00
103,Marie Curie,19.50

Notice that the column names come from the SQL field list, the quotes around string values are cleaned up, and numeric fields like total stay unquoted — exactly what Excel and Pandas expect.

How to Do This in Python and JavaScript

If you need to automate the conversion in code, here are the simplest approaches:

Python

Use sqlalchemy or just parse with sqlite3. The quickest one-liner for a dump file uses Pandas:

import sqlite3, pandas as pd

# Load your SQL dump into a temporary SQLite database
conn = sqlite3.connect(':memory:')
with open('dump.sql', 'r') as f:
    conn.executescript(f.read())

df = pd.read_sql('SELECT * FROM orders', conn)
df.to_csv('orders.csv', index=False)

This loads the SQL dump into an in-memory database, queries it, and writes the CSV. Adjust the table name to match yours.

JavaScript (Node.js)

// Using the 'better-sqlite3' and 'csv-stringify' packages
const Database = require('better-sqlite3');
const { stringify } = require('csv-stringify/sync');
const fs = require('fs');

const db = new Database(':memory:');
const sql = fs.readFileSync('dump.sql', 'utf8');
db.exec(sql);

const rows = db.prepare('SELECT * FROM orders').all();
const csv = stringify(rows, { header: true });
fs.writeFileSync('orders.csv', csv);

Run npm install better-sqlite3 csv-stringify first. The same pattern works for any table name.

How It Works Under the Hood

The converter parses your SQL text and looks for INSERT INTO tablename (col1, col2, ...) VALUES (...) patterns. It reads the column list from the first statement and treats that as the CSV header row. Each VALUES tuple becomes one CSV row.

String values have their surrounding SQL single-quotes removed. Numbers are written as-is. Fields that contain a comma get wrapped in double-quotes to keep the CSV valid — this follows the CSV format standard defined in RFC 4180.

Everything runs client-side in your browser using JavaScript. Your SQL data never leaves your machine.

When to Use This Tool (and When Not To)

Good fitNot the best fit
Exporting rows from a SQL dump to share as a spreadsheetVery large dumps (millions of rows) — use a CLI tool or database client instead
Moving data from a local SQLite or MySQL backup into Excel or Google SheetsComplex SQL with JOINs, subqueries, or stored procedures — paste the raw result set, not the query
Quick one-off data migrations or sharing a snapshot with a non-technical colleagueTables with binary data or BLOB columns — CSV can't represent binary cleanly

For other format needs, you can also convert this same table data to JSON, Markdown, Excel, or 15+ other formats using the same tool — just switch the output format selector.

Working With Your CSV Output

Once you have your CSV, you can open it directly in Microsoft Excel (File → Open), Google Sheets (File → Import), or load it into Python with pd.read_csv('orders.csv'). Most BI tools like Tableau, Power BI, and Looker accept CSV as a data source.

If your workflow involves JSON too, check out our JSON Beautifier for formatting JSON data, or the JSON Validator if you need to check JSON from a database API response for errors. You can also convert JSON to YAML if your target system needs that format.

Tips for Clean Results

  • Include the column list in your INSERT statement (e.g. INSERT INTO t (col1, col2)) — not just INSERT INTO t VALUES. Without it, headers default to generic names like col1, col2.
  • One table at a time gives the clearest output. If your dump has multiple tables, paste each INSERT block separately.
  • Check for encoding issues if your data has accented characters (é, ü, ñ). Save or copy as UTF-8 for best compatibility.
  • If a field value contains a comma or a newline, the tool automatically wraps it in double-quotes — your CSV stays valid.

Paste your SQL above and download your CSV in seconds — it's the fastest path from a database dump to a spreadsheet anyone can open.

Frequently asked questions

Is my SQL data uploaded to a server when I use this tool?+
No. The entire conversion runs in your browser using JavaScript. Your SQL code and data never leave your device, so it's safe to use with sensitive or internal data.
Does it work with MySQL, PostgreSQL, and SQLite dumps?+
Yes. As long as the dump contains standard INSERT INTO statements, the converter handles output from MySQL, PostgreSQL, SQLite, SQL Server, and most other databases. The SQL syntax for INSERT is consistent across all of them.
What if my SQL dump has CREATE TABLE statements too?+
The tool focuses on the INSERT INTO rows to build your CSV. CREATE TABLE, DROP TABLE, and other DDL statements are safely ignored — just paste the whole dump.
How do I convert SQL to CSV in Python?+
The cleanest approach is to load your dump into an in-memory SQLite database using Python's built-in sqlite3 module, then read it into a Pandas DataFrame and call df.to_csv('output.csv', index=False). See the code snippet on this page for the full example.
Can it handle large SQL files with thousands of rows?+
It works well for typical exports — hundreds to tens of thousands of rows. For very large dumps (millions of rows, files over ~50 MB), a command-line tool or your database client's built-in export feature will be faster and more reliable.
What's the difference between exporting SQL to CSV vs. using SELECT INTO OUTFILE?+
SELECT INTO OUTFILE is a MySQL server command that writes a CSV directly on the database server — you need file-system access to retrieve it. This browser tool lets you convert an existing SQL dump file on your own computer without any database connection.
Is this tool free? Do I need an account?+
Completely free, no account needed. Paste your SQL, get your CSV, done.
My CSV output has extra quotes around numbers. How do I fix that?+
This usually happens when the number values in your SQL are wrapped in single quotes (e.g. '49.99' instead of 49.99). The converter treats single-quoted values as strings. Remove the quotes around numeric values in your SQL and re-convert, or use Find & Replace in your spreadsheet app to strip the extra quotes.