What is a SQL to CSV converter?
You often hold SQL text but not a database. A colleague emails a dump file. A backup contains one table you need. A command-line query printed a result you want in a spreadsheet. Restoring a whole dump just to run SELECT and export is a lot of effort for a few rows.
This sql to csv converter reads the text directly. You choose an Input Mode with the pills at the top: SQL INSERT Statements, MySQL Table Output (tabular) or PostgreSQL COPY Output. Paste the text or upload a .sql or .txt file, set the output delimiter, header row and how NULL should appear, and press Convert to CSV.
It is a text parser, not a SQL engine. It does not run queries, evaluate expressions, read CREATE TABLE definitions or filter by table. With INSERT mode, every INSERT in the input is read and the rows are combined into one CSV, with the column names taken from the first INSERT that lists them. If your dump mixes several tables, cut out the one you need first. Backslash escapes inside strings are read the way MySQL writes them.
How to convert SQL data to CSV
- Pick the Input Mode that matches your text. Use the pills to switch, and press Load Sample to see an example of that mode.
- Paste the SQL into the large box or press Upload .sql File.
- Choose an Output Delimiter (comma, tab, semicolon or pipe) and set Include Header Row to Yes or No.
- Choose how NULL values are written: empty string, NULL, null or \N.
- Press Convert to CSV, check the preview table and the row count, then use Download CSV or Copy. The file is saved as export.csv.
What this SQL to CSV tool supports
INSERT parser
Reads single-row and multi-row INSERT ... VALUES statements, including INSERT IGNORE, with or without a column list.
Quote-aware values
Commas, parentheses and semicolons inside quoted strings are kept as part of the value. Doubled quotes and backslash escapes such as \' and \n are unescaped.
MySQL table mode
Understands the +----+ bordered table that mysql prints in a terminal, using the first row as the header.
PostgreSQL COPY mode
Splits tab-separated lines, turns \N into an empty value, restores \t and \n escapes, and ignores a COPY line and the final \. marker.
NULL control
Empty values can be written as nothing, NULL, null or \N, depending on what your target import expects.
Preview and counts
The first 50 rows appear in a table with the total row count, above a text box holding the full CSV.
Who uses it, and for what
- Developers inheriting a dump. You get a mysqldump of one table and only need the rows in a spreadsheet to answer a quick question.
- Data migrators. A source system exports INSERT scripts but the destination, such as Airtable, takes only CSV.
- Support staff pasting terminal output. A DBA runs a query in the mysql client and sends the bordered result. Paste it in tabular mode and get CSV.
- PostgreSQL users. Output from COPY ... TO STDOUT is tab-separated text. Convert it to a quoted CSV a spreadsheet can open, then continue with CSV to Excel.
- Auditors and reviewers. Read data in a SQL script without installing a database server, and compare the rows in a table view.
Tips for getting the right columns
- Cut the dump down to a single table before pasting. Rows from different tables are merged into one CSV, and column counts will not line up.
- If the INSERT statements have no column list, headers become col1, col2 and so on. Rename them in your spreadsheet.
- In tabular mode, a NULL printed by MySQL stays as the text NULL, because it cannot be told apart from the word. Replace it after export if needed.
- PostgreSQL mode has no header row in COPY text, so the header row is generated as col1, col2. Set Include Header Row to No to leave it out.
- Values that are expressions, such as NOW() or UUID(), are exported as that literal text, not evaluated.
- A literal backslash in a PostgreSQL standard string may be read as an escape in INSERT mode, so check Windows paths in the result.
Is it safe? Privacy and limits
Parsing is done by plain JavaScript in your page, with no third-party library and no upload of your SQL. There is no size limit in the code, but very large dump files can slow the tab, since the whole text sits in memory. Dumps often contain personal data, so use a device you trust and remove sensitive rows before sharing the CSV.
SQL to CSV converter FAQ
Open the file in a text editor, copy the INSERT statements for the table you need, paste them into this page in SQL INSERT mode, and press Convert to CSV. If the INSERTs name their columns, you get a proper header row. You can also upload the .sql file directly. Then download export.csv or copy the text. No database server is involved, so nothing needs to be restored or installed.
Yes for data written as INSERT statements. mysqldump produces extended inserts with many rows per statement, which this tool reads. pg_dump uses COPY blocks by default, which is the tab-separated style handled in PostgreSQL COPY mode: paste only the lines between the COPY line and the final backslash-period marker, or paste them with it, since both are skipped. Schema statements such as CREATE TABLE are ignored in INSERT mode. If the dump is compressed, unzip it before pasting.
An unquoted NULL in INSERT mode becomes an empty value, then shows as whatever you pick in the NULL values option: empty, NULL, null or \N. A quoted empty string looks the same as NULL after parsing, so the two cannot be told apart in the output. If that difference matters, check the original SQL, or export directly from the database with a SELECT statement. If you are loading the CSV somewhere that treats the word NULL as text, choose the empty option to avoid it ending up in the data.
No. It is not a SQL engine. It does not execute SELECT, JOIN or WHERE clauses, and it does not read table definitions. It only extracts literal values from INSERT statements, tabular text or COPY output. For query results, run the query in your database client and export from there, or paste the printed table into MySQL tabular mode as long as it uses the bordered format. For complex queries, running them in your database client is the better route.
Usually the wrong mode. If you see the message that no data rows were found, the text does not match the selected mode: INSERT mode needs INSERT INTO ... VALUES, tabular mode needs lines containing pipe characters, and COPY mode needs tab-separated lines. Misaligned columns usually mean the dump holds several tables, or a value contains an unusual construct. Check a few lines of the preview against the source. Switching the Input Mode pill hides the old output, so press Convert again after you change it.
No. The parsing code runs on the page and your SQL is not transmitted anywhere by this tool. That makes it reasonable for internal dumps, though you should still follow your organisation's policy for personal or regulated records. The converted CSV only exists in the text box until you download or copy it, and clearing the input or reloading the page removes it. If you need a record of what was converted, keep the original SQL file, because this page keeps nothing after you leave it.
Use the CSV to SQL converter, which writes CREATE TABLE and batched INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server and lets you adjust the column types. For a spreadsheet instead, open the CSV with the CSV to Excel converter. If the data is JSON rather than SQL, the JSON to Markdown tool covers documentation tables. The CSV you download can also be opened directly in any spreadsheet program.