Convert MySQL Output to CSV Online

Paste the output of a MySQL query, box and all, and get a CSV. The plus signs, dashes and the row count line are stripped, and the pipes become the columns.

From

The only part of this site that uses a server. The address is sent to it so the page can be fetched, because a browser is not allowed to fetch someone else's page itself. Your own files are never involved.

Nothing here is uploaded. The parsing happens on this page.
Edit
Paste or upload something above and it will appear here.
ToDataMarkupDocumentsCodeSchemasImages

The output will appear here once there is a table to convert.

What MySQL Output is

Not a file format at all. It is what the MySQL command line prints when you run a query: a box drawn with plus signs, dashes and pipes, with a line underneath saying how many rows were in the set.

Anyone who has run a query in a terminal and wants the answer in a spreadsheet.

What CSV is

CSV is a text file where each line is a row and commas separate the fields. There is no type system, no formatting and no second sheet. Every value is text until something downstream decides otherwise.

Almost every database, analytics tool and spreadsheet can read and write it, which is why exports default to it.

What changes when you convert MySQL Output to CSV

The rules and the trailing row count are dropped and the pipes become column boundaries. MySQL prints an unset value as the four characters NULL, which arrives here as an empty cell, because that is what NULL means and because a literal string of NULL in a spreadsheet is worse than a blank. Paste it as CSV instead and every row becomes one column full of pipes, which is why this is its own format.

Any value containing the delimiter, a quote or a line break gets wrapped in quotes, and embedded quotes are doubled. That is the rule in RFC 4180 and it is what spreadsheet software expects.

The +---+---+ rules are dropped and so is the trailing line that says how many rows were in the set. Neither is data, and both end up as rows if you paste the block into anything that reads it as delimited text.

NULL becomes an empty cell. MySQL prints an unset value as the four characters NULL, which is a different thing from a value that happens to be the word NULL. The distinction matters and this side of it is the far more common one.

Values are trimmed of the padding MySQL adds to line the box up. That padding is presentation, not part of the value.

What carries over from MySQL Output to CSV

MySQL records 3 things about a table that CSV has no way to hold.

MySQL distinguishes a number from the text of a number; CSV does not, so every value arrives as text and has to be re-parsed by whatever reads it next.

An empty cell and a missing one are the same thing in CSV, so a null and an empty string in the MySQL both come out blank and can no longer be told apart.

CSV has no separate idea of a header, so the column names become an ordinary first row and nothing in the file marks them as different from the data.

The identifier 007 comes out of the CSV as 007. Reading it as a number would have made it 7, and an id that changes value is worse than one that stays text.

The role "Analyst, data" survives with its comma, in one cell rather than split across two. That is the first thing to check in any converted table, and the usual place a CSV file goes wrong.

The quotes around Jonah "Jo" Pryce are doubled, which is how the delimited formats escape a quote in the CSV.

A worked example

Three rows of staff data, with an identifier that has a leading zero, a value containing a comma, a value containing quotes and one blank cell. Those are the four places formats disagree, so they are the four places to look.

MySQL Output in
+-----+------------------+---------------+------------+-------+
| id  | name             | role          | started    | hours |
+-----+------------------+---------------+------------+-------+
| 007 | Halima Yusuf     | Analyst, data | 2024-03-15 | 38.5  |
| 012 | Jonah "Jo" Pryce | Engineer      | 2025-11-02 | NULL  |
| 104 | Wei Chen         | Manager       | 2023-06-30 | 40    |
+-----+------------------+---------------+------------+-------+
3 rows in set (0.00 sec)
CSV out
id,name,role,started,hours
007,Halima Yusuf,"Analyst, data",2024-03-15,38.5
012,"Jonah ""Jo"" Pryce",Engineer,2025-11-02,
104,Wei Chen,Manager,2023-06-30,40

Questions

How do I convert MySQL Output to CSV?

Paste your MySQL Output into the box above or drop the file onto it. Check the table in the grid, then copy or download the CSV from the output panel. It takes one step and the data never leaves your browser.

Can I paste output from psql or sqlite3 as well?

psql draws its box with different characters and is not read here. Both psql and the MySQL client can print tab-separated output instead, which is detected as TSV and is the more reliable route for either: mysql -B, or \pset format unaligned and \pset fieldsep in psql.

Why does my CSV open with all the data in one column?

The file uses a delimiter your spreadsheet did not expect. Exports from European locales often use semicolons because the comma is the decimal separator there. Change the delimiter in the export options and the columns split correctly.

Is there a better way than pasting the box?

Yes. Run the client with mysql -B and it prints tab-separated output instead of the box, which has no padding to trim and no ambiguity about values containing a pipe. That output is detected as TSV here. The box is what you have when you already ran the query, which is the case this page is for.

My values contain pipe characters and the columns are wrong.

The box format has no way to escape a pipe inside a value, so a value containing one genuinely is ambiguous. Re-run with mysql -B, or use SELECT ... INTO OUTFILE, both of which quote properly.

Will my numbers still be numbers?

They will read the same, but CSV stores them as text. Anything that sorts or sums the result will need to parse them first, and a leading zero or a currency symbol is the usual place that goes wrong.

Is there a limit on file size?

No. The work happens on your own machine, so the limit is your machine's memory rather than an upload cap. A file with tens of thousands of rows converts in a second or two.

Is my data uploaded anywhere?

No. The parsing and generating are done by JavaScript running on this page. You can watch the network tab while you convert and see that nothing is sent.

Related conversions