Your query worked. The terminal drew a neat table, rows lined up, columns straight. Then you copied it into a spreadsheet and the whole thing landed as one wide column of text, borders, dashes and all. Nothing sorts, nothing filters, and the chart button just stares at you.

The problem is that terminal output only looks like a table. It is text with decoration, and a spreadsheet needs structure: a header row and rows of comma-separated values. This guide shows how to get from the paste to a genuinely spreadsheet-ready file with the free SQL to CSV Formatter on Ovatly, and how to check the result before you build anything on it.

Contents

  • Quick answer
  • Why terminal output is not spreadsheet-ready
  • The formats the converter can read
  • How to convert query output, step by step
  • Worked example: a MySQL table becomes a CSV
  • Check the converted file before you build on it
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

Run your query, copy the printed table, and paste it into the SQL to CSV Formatter. Leave the format on Auto-detect, or pick the format yourself if you know it. Convert, then download the result as query-result.csv. Before you use the file, count its data rows against the count the terminal reported, and open it once to confirm that a value containing a comma still sits inside a single cell.

Why terminal output is not spreadsheet-ready

A spreadsheet-ready file has a strict shape: the first row names the columns, and every row after it holds one record, with the values separated by commas. Open that file and each value lands in its own cell, ready to sort, filter and total.

Terminal output has a different job. It is drawn for human eyes on a fixed-width screen. Column borders are pipe characters, the header is underlined with dashes and plus signs, and every value is padded with spaces so the columns line up visually. None of that tells a spreadsheet where a value starts or ends. Pasted raw, each printed line becomes one long cell, and the padding spaces make even manual splitting unreliable.

The conversion is therefore a translation, not a tidy-up: read the drawn table, recover the values, and write them back out in the delimited shape a spreadsheet understands.

The formats the converter can read

The formatter accepts the shapes database clients actually print:

  • MySQL ASCII tables, with their +---+ borders and pipe-separated columns.
  • psql output, where a dashed separator line sits under the header.
  • Whitespace-aligned columns with a dashed separator, the style several other clients use.
  • Tab or semicolon delimited text, for output that was already separated but not in CSV form.
  • A fallback for columns separated by two or more spaces, when there is no separator line at all.

You can leave detection on Auto-detect and let the tool work out which shape you pasted, or pick the format yourself when you know it. Picking it yourself is the fix worth trying first when a conversion comes out wrong, because it removes the guesswork.

How to convert query output, step by step

  1. Run your query in your own database client and copy the complete printed output, header and separator line included.
  2. Open the SQL to CSV Formatter and paste the output in.
  3. Leave the format on Auto-detect, or choose the format that matches your client.
  4. Press Convert and download the result as query-result.csv.
  5. Open the CSV in your spreadsheet and run the checks in the next section before you sort, filter or chart anything.

Two details of the conversion are worth knowing. The padding spaces around each value are trimmed, so Ana arrives as Ana and not as a value with stray spaces attached. And the summary line the terminal prints at the end, such as (3 rows), is removed deliberately: it is a note about the table, not a row of it.

Worked example: a MySQL table becomes a CSV

Suppose a MySQL query prints this small table of people:

+----+------+
| id | name |
+----+------+
| 1  | Ana  |
| 2  | Ben  |
+----+------+
2 rows in set (0.00 sec)

Pasted into the formatter and converted, the download reads:

id,name
1,Ana
2,Ben

The borders and the separator row are gone, the padding around Ana and Ben is trimmed away, and the "2 rows in set" line is dropped. What is left is exactly the spreadsheet-ready shape: a header row naming the two columns, then one comma-separated row per record. Opened in a spreadsheet, id and name become two real columns, and the numbers sort as numbers.

Check the converted file before you build on it

A converted file that opens cleanly can still be wrong, and every total or chart you build will inherit the error. Two checks take under a minute.

First, count. The terminal told you how many rows the query returned; in the example above it said 2 rows. Your CSV should hold that many data rows, plus one header row. If the counts disagree, a row was probably split or merged during conversion, and the file is not ready.

Second, spot-check a value that contains a comma, if your results have one, such as a city and region stored in a single field. Open the CSV and confirm that value sits inside one cell rather than spilling into the next column. If it spilled, the paste was most likely read as the wrong format: go back, pick the format manually instead of relying on Auto-detect, and convert again.

Limitations and honest tradeoffs

The tool reads printed output, and printed output has already thrown information away. A NULL and a value that genuinely contains the word NULL look identical in the terminal, so both arrive in the CSV as the text NULL. Values that begin or end with meaningful spaces lose them, because padding and real spaces cannot be told apart and the padding is trimmed.

Pipe characters inside values break ASCII table parsing, as the FAQs explain, because the parser cannot distinguish a value's pipe from a border's pipe. And the tool never runs SQL and has no database connection: if the query itself was wrong, the CSV will be a beautifully formatted copy of the wrong answer.

Common mistakes

  • Pasting terminal output straight into the spreadsheet. It lands as one column of decorated text. Convert first, paste second.
  • Trusting the file because it opened. A split row still opens. Count the rows against the terminal's own count.
  • Leaving Auto-detect on after a bad conversion. Pick the format yourself and convert again before blaming the data.
  • Forgetting that NULL is text now. In the CSV it is the literal word NULL, and a spreadsheet will treat it as text, not as an empty cell.
  • Converting a partial paste. If you copy only part of the printed table, the CSV will be a tidy file of incomplete results, and nothing will warn you.

FAQs

Why does pasted query output open as one column in my spreadsheet? Because terminal output is text decorated with borders and padding spaces, not delimited data. A spreadsheet cannot tell where one column ends and the next begins. Converting the paste to CSV first gives it a header row and comma-separated values it can split into real columns.

Which terminal formats can the converter read? MySQL ASCII tables with +---+ borders, psql output with dashed separators, whitespace-aligned columns with a dashed separator line, tab or semicolon delimited text, and as a fallback, columns separated by two or more spaces.

Does the tool run my SQL query for me? No. The tool never runs SQL and has no database connection. You run the query in your own client, paste the printed output into the tool, and the conversion happens locally in your browser.

What happens to NULL values in the results? A NULL is copied into the CSV as the literal text NULL, exactly as the terminal printed it. Keep that in mind when you read the file later: the word NULL in a cell means the database stored no value there.

Why did one of my rows split into extra columns? In an ASCII table the parser treats each pipe character as a column border, so a value that itself contains a pipe breaks that row. Re-run the query so the value has no pipe in it, or paste the results as tab or semicolon delimited text instead, which the converter also accepts.

Conclusion

Spreadsheet-ready is a shape, not a hope: a header row, comma-separated records, and a row count that matches what the terminal reported. The SQL to CSV Formatter does the translation from drawn table to that shape in your browser. Once the file checks out, hand it to anyone who needs the numbers, a job our companion guide on sharing query results with a non-technical teammate covers. For more guides in this series, see our Data and JSON Tools guides.

References