tsvkit.org
TSV Toolkit
Sample data Say hi →

TSV Header Tools

add · remove · rename · snake_case · lower · upper · trim · de-duplicate

The header row causes a disproportionate share of TSV problems. A file exported without one can't be addressed by column name. A header with spaces and capitals in it needs quoting in every SQL statement it touches. Two columns called date break any tool that indexes by name. And a header with a stray trailing space means the name you type never matches. All of that is fixed here in one pass.

header
Drop a .tsv file here, or
ready

How to use

  1. Paste or drop the file.
  2. Pick an action. Only rename and add use the Names field.
  3. For rename, list the new names in column order — leave an entry empty to keep that column's existing name, and give fewer names than there are columns to rename only the leading ones.
  4. For add, either supply names or leave the field blank to get column_1, column_2, and so on.

snake_case, and why it's the default

Order Date becomes order_date; Total (USD) becomes total_usd; Ünïcode Nàme becomes nicode_nme — non-ASCII letters are dropped rather than transliterated, which is the one case where you'll want to check the result. Names are lower-cased, runs of non-alphanumerics collapse to a single underscore, and leading and trailing underscores are trimmed.

The reason to do this before anything else: a snake_case name is a valid identifier in SQL, Python, R, and JSON without quoting. Everything downstream gets simpler — no SELECT "Total (USD)", no df["Order Date"]. Both snake_case and make unique also de-duplicate: if two columns would end up with the same name, the second becomes name_2, the third name_3. That's what keeps a name-indexed reader from silently dropping one of them.

Add and remove

Add is for the headerless files that command-line exports produce — psql -t, mysql -N, a .bed file. The number of columns is taken from the widest row, so a ragged file gets a header wide enough for all of it. Supplying real names immediately makes every other tool on this site usable by name rather than by position.

Remove is for feeding a loader that expects bare data, or for treating the first row as data after a bad export made a data row into the header. If you remove a header by mistake, the fix is add — but the original names are gone, so keep a copy.

FAQ

How do I rename just one column in the middle?

List the names up to and including it, leaving the ones you want unchanged as empty entries: ,,new_name renames only the third column. Trailing columns you don't mention keep their names.

Does it change the data rows at all?

No, except for add (which prepends a row) and remove (which deletes one). All the other actions touch only row one.

How do I reorder columns?

Extract columns — name them in the order you want and the output follows that order. It doubles as a reorder tool.

What if my header is on the second row?

Common with spreadsheet exports that put a title above the table. Delete the first row with slice rows using range from 2, then come back here.

Privacy

100% client-side. No upload. See the privacy policy.