TSV to CSV Converter
How it works
TSV (Tab-Separated Values) and CSV (Comma-Separated Values) are both plain-text tabular formats, but they differ in their delimiter choice and quoting requirements. TSV files use a tab character ( ) as separator; because tabs rarely appear in data values, TSV files often require no quoting at all. CSV uses a comma and must quote values that contain commas, newlines, or double quotes.
**When to convert** Spreadsheet software: Microsoft Excel opens both TSV and CSV, but CSV is the default for most import dialogs. Python pandas read_csv requires sep=' ' for TSV; converting to CSV removes this friction. Databases: PostgreSQL's COPY command defaults to tab-separated; MySQL's LOAD DATA INFILE defaults to comma-separated. Many web APIs consume CSV rather than TSV for data upload endpoints.
**Conversion edge cases** Values containing tabs: TSV data may contain tab characters within quoted fields (unusual but valid). These must be preserved as literal tab characters (not treated as delimiters) during parsing. Values containing commas in the source: once converted to CSV, these values must be quoted with double quotes. Newlines within field values: both formats can technically contain embedded newlines in quoted fields, but many CSV parsers choke on them — inspect and handle these during conversion.
**RFC 4180 compliance** The de facto CSV standard (RFC 4180) specifies: CRLF line endings, optional header row, double-quote enclosure for fields containing commas/quotes/newlines, doubled double-quotes as the escape mechanism. Converting TSV to CSV that complies with this standard maximizes compatibility.
Frequently Asked Questions
- Embedded tab characters within quoted TSV fields are preserved as literal tabs (not treated as delimiters) during parsing. In the CSV output, these tab characters are preserved within quoted fields. If you need to remove embedded tabs (e.g., for systems that cannot handle them), replace them with spaces or a placeholder during conversion. RFC 4180 CSV technically allows tabs within quoted fields, though some parsers may mishandle them.
- On Linux/macOS using sed: sed 's/ /,/g' file.tsv > file.csv — but this does not handle commas within fields. Better: use Python: python3 -c "import csv,sys; csv.writer(sys.stdout).writerows(csv.reader(sys.stdin, delimiter=' '))" < file.tsv > file.csv. This properly handles quoting. On Windows PowerShell: (Get-Content file.tsv) -replace ' ',',' | Set-Content file.csv (same caveat — no quoting protection).
- Yes. Rename the file with a .txt extension, then open it in Excel and the Text Import Wizard will detect tab as the delimiter. Or use Data → Get External Data → From Text. Excel also opens .tsv files directly in some versions. When opening directly (double-click), Excel may not detect tab-separated format — the Text Import Wizard approach is more reliable. Once open, save as .csv using File → Save As.
- Both TSV and CSV are plain text — the key encoding question is whether the file is UTF-8, UTF-16, or a legacy encoding (Windows-1252, ISO-8859-1). UTF-16 files have a BOM (Byte Order Mark) at the start. Python's csv module defaults to the system encoding; specify encoding='utf-8-sig' to handle UTF-8 with BOM. Mismatched encoding produces mojibake (garbled characters) in non-ASCII characters like accented letters, Chinese characters, or emojis.