Count TSV Columns
Count the number of columns in TSV (Tab-Separated Values) data instantly. Paste or upload TSV files to analyze column structure and detect inconsistencies.
| Row | Columns | Status | Preview |
|---|
About
Miscounting columns in tab-separated data causes silent failures in database imports, broken ETL pipelines, and corrupted analytics. A single missing tab character shifts every downstream field, producing results that look plausible but are wrong. This tool parses raw TSV input and reports the exact column count per row, flagging inconsistencies where row i has a different field count than row j. It handles edge cases including trailing tabs, empty fields, and BOM-prefixed files. The column count for any row equals ntabs + 1, where ntabs is the number of tab characters on that line.
Note: this tool treats every tab as a delimiter. It does not support quoted fields containing literal tab characters, which is rare in TSV but common in CSV. For files exceeding a few thousand rows, performance remains instantaneous since the algorithm is O(n) in total character count. Pro tip: if your data originated from a spreadsheet export, check for trailing tabs appended to empty trailing columns.
Formulas
The column count for any single row in a TSV file is derived from the number of tab delimiter characters present on that line:
Where C is the column count for the row and ntabs is the number of U+0009 (horizontal tab) characters found in that row. For the full file consistency check, the tool computes Ci for every row i and reports whether all values are equal:
Where m is the total number of non-empty rows. If any Ci ≠ C1, the tool flags those rows as inconsistent and reports both the expected count (from row 1) and the actual count.
Reference Data
| Scenario | Tab Count Per Row | Column Count | Common Cause | Risk Level |
|---|---|---|---|---|
| Standard 3-column TSV | 2 | 3 | Normal export | None |
| Single column (no tabs) | 0 | 1 | Wrong delimiter or plain text | High |
| Trailing tab on every row | 3 | 4 | Spreadsheet export artifact | Medium |
| Inconsistent row lengths | Varies | Varies | Missing fields, manual editing | Critical |
| Empty row (blank line) | 0 | 1 or skipped | Trailing newline in file | Low |
| Header has more columns than data | n | n + 1 | Schema change, column added to header only | Critical |
| BOM-prefixed UTF-8 file | 2 | 3 | Windows Notepad save | Low (if stripped) |
| Tab inside quoted field | Overcounted | Overcounted | CSV-style quoting in TSV | Medium |
| Mixed delimiters (tab + comma) | Varies | Varies | Copy-paste from mixed sources | High |
| 10-column dataset | 9 | 10 | Standard wide table | None |
| 100-column dataset | 99 | 100 | Genomic/scientific data | None |
| Row with only tabs | n | n + 1 | All fields empty | Medium |
| Windows line endings (\r\n) | 2 | 3 | Cross-platform file transfer | Low (if handled) |
| Last row missing newline | 2 | 3 | Truncated file or stream | Low |