CSV to TSV Converter

Convert CSV to TSV or TSV to CSV with correct quoting for commas, tabs, quotes and line breaks.

Back to tools

How to convert CSV to TSV and TSV to CSV

This converter changes comma-separated values into tab-separated values and back again. Pick a direction with the CSV to TSV and TSV to CSV tabs, paste your data, and the converted table appears as you type. It is handy when a spreadsheet gives you tab-separated text but an importer wants CSV, or when CSV full of commas is easier to read and paste as TSV.

Instead of swapping delimiters with find and replace, the tool parses each row properly. Quoted cells that contain commas, tabs, double quotes or line breaks stay in one cell, and the output adds quotes only where the target format needs them. Conversion runs in your browser.

How to use it

  1. Choose CSV to TSV or TSV to CSV at the top of the tool.
  2. Paste your data into the Input CSV or Input TSV box. The output updates automatically after a short pause.
  3. Optionally turn on Trim values to remove spaces around each cell, or Skip empty lines to drop blank rows. Reset to defaults turns both off again.
  4. Check the Output TSV or Output CSV panel and the Rows badge. If the input has a quoting problem, the error appears in the output and the affected input line is highlighted.
  5. Click Copy output, or use Swap input and output to move the result into the input and flip the direction.

Examples

CSV with quoted cells to TSV

In CSV to TSV mode, Wilmslow, UK no longer needs quotes because commas are not special in TSV. The cell with doubled quotes and the cell with a line break are still quoted, with inner quotes doubled, so they stay one cell each.

Input CSV
name,city,notes
Ada,London,"Loves ""math"", tea"
Alan,"Wilmslow, UK","Line one
Line two"
Output TSV
name	city	notes
Ada	London	"Loves ""math"", tea"
Alan	Wilmslow, UK	"Line one
Line two"

TSV pasted from a spreadsheet to CSV

In TSV to CSV mode, the description Small, blue contains a comma, so it is wrapped in quotes in the CSV output. Cells without commas, quotes or line breaks are written as they are.

Input TSV
product	price	description
Widget	9.99	Small, blue
Gadget	12.50	Pack of 3
Output CSV
product,price,description
Widget,9.99,"Small, blue"
Gadget,12.50,Pack of 3

Cleaning up spaces and blank rows

With Trim values and Skip empty lines both on, the spaces around each cell are removed (including the trailing space inside the quoted "Alan ") and the blank second line is dropped. The Rows badge shows 3.

Input CSV
id, name , score

1, Ada , 98
2,"Alan ", 91
Output TSV
id	name	score
1	Ada	98
2	Alan	91

How quoting works in each direction

Both directions read the input with RFC 4180 rules: a cell that starts with a double quote can contain the delimiter, line breaks and quotes written as "", and it ends at the next double quote that is not doubled. The double quote is the quote character for TSV input as well as CSV.

When writing the output, a cell is wrapped in double quotes only if it contains the output delimiter, a double quote or a line break. Any double quotes inside the cell are doubled. Everything else is written without quotes, so the output stays as close to the input as possible.

  • CSV to TSV: cells that contained commas lose their quotes, because a comma is ordinary text in TSV. Cells with tabs, quotes or line breaks keep them.
  • TSV to CSV: cells that contain commas gain quotes, so spreadsheet apps do not split them into extra columns.
  • Rows are separated by a single line feed (\n) in the output, whether the input used Windows CRLF or Unix LF line endings.

Trim values and Skip empty lines

Both switches are off by default, so the converter keeps your data byte for byte apart from the delimiter and the necessary quoting. With them off, a blank line in the input becomes a blank line in the output, and spaces after commas stay part of the cell.

Trim values removes leading and trailing whitespace from every cell after parsing, including quoted cells. Skip empty lines removes rows where every cell is empty, which also drops a trailing blank line at the end of a pasted file. Turn them on when cleaning up exports before importing them elsewhere, and leave them off when spaces are meaningful.

Errors and limitations

If a quoted cell is never closed, the output shows Unclosed double quote. If text follows a closing quote in the same cell, as in "abc"x, it shows Stray double quote in quoted field (use "" for a literal quote). In both cases the line is highlighted in the input so you can fix it. The same messages appear in TSV to CSV mode.

A double quote only starts a quoted cell when it is the first character of the cell. Anywhere else it is kept as literal text, so unquoted TSV copied from a spreadsheet, such as 27" monitor, converts as-is. When the output is CSV, that cell is quoted and the inner quote doubled: "27"" monitor".

Rows are not padded or truncated. A row with fewer cells than the header is converted with the cells it has, so check the Rows count and the output when the source file is irregular.

Privacy

Your data is parsed and converted in the browser and never uploaded. The current input, direction and switch settings are saved in this browser's local storage so they survive a page reload. Click Clear input to remove the saved data.

Related tools

More utilities that pair well with this one.

Frequently asked questions

Common questions about this tool.