What is a TSV file, and what does this generator make?
A TSV (tab-separated values) file is a plain-text table: each line is one record and a tab character separates the values within it. This generator fills such a table with random 8-character strings of letters and digits, from 1 to 50 rows and 1 to 10 columns, ready to paste into a spreadsheet or pipe into a command-line script.
Why tabs instead of commas?
Commas show up in ordinary data all the time (addresses, prices, prose), so CSV needs a quoting system to tell a separator from content. Tabs almost never appear in real values, so TSV mostly skips the problem. The IANA registration for text/tab-separated-values settles it bluntly: fields containing tabs are simply not allowed, and there is no escape mechanism at all.
That trade-off makes TSV the format of choice for:
- Clipboard transfer. Spreadsheets copy cells to the clipboard as tab-separated text and paste it back the same way.
- Unix pipelines.
cut,sortandawkhandle tab-delimited columns with almost no options. - Database exports. PostgreSQL's
COPYuses a tab as its default delimiter in text format.
Creating a grid
- Choose the number of Rows (1 to 50).
- Choose the number of Columns (1 to 10).
- Click Generate, then Copy.
- Paste into cell A1 of a spreadsheet, or into a file named
sample.tsv.
Two rows and three columns came out like this:
uD3k2PBl 1NPcG7EJ kX5iU5lt
YIm1ldr4 Ix6UxhwC uw3IvZ4V
Values are built in the browser from crypto.getRandomValues(); the page sends nothing to a server.
Checking the output against the IANA rules
| IANA requirement | Generated output |
|---|---|
| First line contains the field names | Not included; add your own |
| Each record is a single line | Yes, rows end with a line feed |
| Every record has the same number of fields | Yes |
| Fields may not contain tabs | Guaranteed, values are alphanumeric |
The missing header is easy to fix and worth fixing if the file is going into a library like pandas, which treats the first line as column names by default and would otherwise turn your first random row into headers.
Seeing and using the tabs
In the output box a tab renders as whitespace up to the next tab stop, so columns can look ragged or appear to be separated by a variable number of spaces. They aren't. On Linux you can prove it with cat -A sample.tsv (on macOS, cat -t), which shows each tab as ^I.
Once saved, the file works with standard tools without extra flags, because cut splits on tabs by default:
cut -f2 sample.tsv # second column
awk -F'\t' '{print $3, $1}' sample.tsv # reorder columns
sort -t$'\t' -k2 sample.tsv # sort by column 2
In Python, csv.reader(f, delimiter='\t') reads the same file. If shell scripting is new to you, the Bash overview is a good starting point.
When to pick TSV and when to pick CSV
| Situation | Better choice |
|---|---|
| Pasting into Excel or Google Sheets | TSV, it lands as cells |
| Uploading to a web app's import screen | Usually CSV, it's the more common upload format |
Processing with cut or awk |
TSV |
| Data that may legitimately contain tabs | CSV, which can quote them |
If your target wants commas, the random CSV generator produces the same kind of grid with comma separators. For a single long random token rather than a grid, use the random alphanumeric generator, and to turn a grid into web markup, paste it into the HTML table generator.
Last updated