SQL to CSV Converter
Database dumps and pasted query results back into tables, without a database.
Try before you buy.
- Free preview: a summary and the first rows of the result (up to 10; a single row is shown with its results hidden).
- Locked until you unlock it: download and copy.
- Unlock: Pro pass, ₹179 for 30 days, a one-time payment that never renews.
Ways to unlock shows how to get the full result.
Printing this result is locked in the free preview.
Your SQL
INSERT or COPY statements, a whole dump, or a result copied from the MySQL, psql or SQLite console. For large dumps use Open a file: any size works there.
MySQL and MariaDB dumps use them; PostgreSQL, SQLite and SQL Server do not.
Tables
Save
Locked in the free preview. Opens the ways to unlock this result.
Locked in the free preview. Batch runs unlock with a pass.
Locked in the free preview. Query results unlock with a pass.
About the SQL to CSV Converter
Turn SQL back into tables. Paste INSERT statements or open a database dump — a mysqldump or MariaDB backup, a pg_dump file, a SQLite .dump, a SQL Server script — and every table in it comes out as its own CSV, Excel sheet or JSON file, with its real column names. Dumps of any size are read piece by piece in your browser, gzip-compressed ones (.sql.gz) too, and never uploaded.
The reader follows each database’s own rules for text: doubled quotes (O''Brien), MySQL’s backslash escapes (It\'s, \n), PostgreSQL’s E'…' strings and $$ quoting, N'…' strings, NULL, and hex and binary values (0x89504E47, X'…', b'1', _binary '…'). Multi-row VALUES, column lists, MySQL’s INSERT … SET and REPLACE, and PostgreSQL’s COPY … FROM stdin data — the way pg_dump writes tables by default — are all read; CREATE TABLE gives the column names when the INSERTs leave them out, as mysqldump does.
It also turns query results copied from a console into tables: the MySQL client’s +----+ boxes, psql’s grid and its expanded \x display, SQLite’s box tables and the MySQL client’s vertical \G output. Without a pass, the free preview shows every table with its row count and its first rows; the files and copying unlock with a Pro pass.
How to use it
- Paste SQL into Your SQL, or choose Open a file and pick a .sql or .sql.gz file. Try an example loads a small MySQL dump.
- The dialect is detected (MySQL, PostgreSQL or standard SQL). If quotes come out wrong, set Backslash escapes: MySQL style reads
\'as a quote; standard SQL keeps backslashes as they are. - Check the tables: each one with its columns, its rows and its first rows, and any statements that could not be used, with their line numbers.
- Choose CSV, TSV, Excel, JSON or JSON Lines, and this table or all of them (several tables come as a ZIP of files, one workbook or one JSON object). With a pass, or after unlocking this result, press Download or Copy; without one, the free preview shows the first rows.
Examples
CREATE TABLE `users` (`id` int, `name` varchar(50), `bio` text); INSERT INTO `users` VALUES (1,'Asha','It\'s \"quoted\"'),(2,'O''Brien',NULL);
id,name,bio 1,Asha,"It's ""quoted""" 2,O'Brien,
The column names come from CREATE TABLE; NULL becomes an empty cell (or the text NULL, if you choose).
COPY public.orders (id, customer, amount) FROM stdin; 1 Asha 120.50 2 Ravi \N \.
id,customer,amount 1,Asha,120.50 2,Ravi,
Fields are separated by tabs and \N is NULL; the line \. ends the data.
+----+------+ | id | name | +----+------+ | 1 | Asha | +----+------+
id,name 1,Asha
Common uses
- Getting a table out of a database backup without installing MySQL or PostgreSQL.
- Opening a .sql export from a hosting control panel or an app in Excel.
- Turning seed data or test fixtures written as INSERT statements into CSV or JSON.
- Moving data between databases that speak different SQL: dump, convert to CSV, load elsewhere.
- Saving a query result copied from a terminal as a spreadsheet.
How text in quotes is read
- Every dialect: two quotes inside a quoted string are one quote (
'O''Brien'), and strings written side by side are joined. - MySQL and MariaDB also read backslash escapes:
\'\"\n\r\t\0\Z\\, and a backslash before any other character is dropped (MySQL: String Literals)."…"is a string there and `…` a name. - PostgreSQL and standard SQL keep backslashes as they are, except in
E'…'strings;"…"is a name, and$$…$$or$tag$…$tag$holds text exactly as written (PostgreSQL: Lexical Structure). - COPY … FROM stdin data is read in COPY’s text format: fields separated by tabs,
\Nfor NULL, backslash escapes, and a line\.at the end (PostgreSQL: COPY).
Values that are not plain text
Numbers keep every digit as written (Excel gets numbers of more than 15 digits as text, because it keeps only 15). Hex and binary values (0x…, X'…', mysqldump’s --hex-blob output) can be written as 0x hex, as text when they hold valid UTF-8, or as base64. TRUE and FALSE become true and false. Casts keep their value ('42'::int is 42), and other expressions such as NOW() are written as their SQL text, which the summary counts.
Limitations
- Only data written in the dump is read:
INSERT … SELECTcopies rows from a query and has no values here, and is reported. Nothing is run, so no triggers or defaults fill anything in. - Rows with a different number of values than the table’s columns are left out and reported, as a database would refuse them.
- COPY data in CSV or binary format is not read (pg_dump uses the text format, which is).
- Query results are read whole: pasted results and files up to 64 MB of text. Dumps of statements have no size limit.
- Excel sheets hold at most 1,048,576 rows; choose CSV for larger tables.
Privacy
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
What do I get without a pass?
Without a pass, SQL to CSV Converter shows a summary and the first rows of the result (up to 10; a single row is shown with its results hidden). Until you unlock it, the result can’t be downloaded or copied. A Pro, Premium or Ultimate pass, a one-time payment that never renews, unlocks the full result. The pricing page lists the passes and their prices.
How do I convert a .sql file to CSV?
Open the file here (or paste the INSERT statements). Every table in it is listed with its rows; pick one, or all of them, choose CSV and, with a pass, press Download. Several tables come as a ZIP with one CSV each.
Can it open a mysqldump or pg_dump backup?
Yes. mysqldump writes CREATE TABLE and multi-row INSERT statements; pg_dump writes COPY … FROM stdin data by default, or INSERT statements with --inserts. Both are read, also when the file is gzip-compressed (.sql.gz). Statements that are not data — SET, LOCK TABLES, indexes, functions, triggers — are skipped and counted.
Why are my quotes or backslashes wrong?
MySQL dumps use backslash escapes (It\'s); other databases do not, and a Windows path such as C:\new would change if they did. The dialect is detected from the dump; if it guesses wrong, set Backslash escapes to MySQL style or to standard SQL.
How do I turn a MySQL or psql result into CSV?
Copy the result with its borders from the terminal and paste it here: the +----+ boxes, psql’s grid with the ----+---- line (values over several lines too), psql’s expanded -[ RECORD 1 ]- display, SQLite box tables and \G output are found, even several in one paste. Columns are cut at the border’s positions, so a value holding a | stays whole.
Is my database uploaded?
No. The file is read in your browser, piece by piece, and nothing is sent anywhere.