Tab delimited character code

The tab that separates fields in tab-delimited text is U+0009 (decimal 9, hex 09). Learn how to identify it by code, reveal it, and use it as a delimiter safely.

The character that separates fields in a tab-delimited file is the horizontal tab. Its Unicode code point is U+0009, which is 9 in decimal. It is invisible and often looks like several spaces, so checking its code is the most reliable way to tell whether a gap in your text is really a tab. This guide covers the tab's code in common notations, how to detect it in several tools, and how to confirm the result without changing your data.

The tab character code at a glance

Representation | Value
Unicode code point | U+0009 (Unicode name alias: CHARACTER TABULATION)
Decimal | 9
Hexadecimal | 0x09
Octal | 011
Binary | 00001001
ASCII name | HT (horizontal tab), a control character
UTF-8 encoding | one byte: 09
UTF-16 code unit | 0009
Escape sequence (C, Python, JavaScript, Java and many others) | \t
Caret notation and keyboard | ^I (Ctrl+I)
HTML or XML numeric reference | or
URL percent-encoding | %09
Spreadsheet function (Excel, Google Sheets) | CHAR(9)

What the tab does in tab-delimited text

In a tab-delimited file, often called TSV, each line is one record and each U+0009 marks the boundary between two fields. A program that reads the file splits each line on that single byte, and the result is a set of columns. Only U+0009 counts as the delimiter. Spaces or other blank characters that look identical on screen do not split fields, and they are the most common reason a TSV import produces the wrong number of columns.

The width a tab appears to have on screen depends on the editor's tab-stop setting. That width is display only. The file still contains one byte, 09, no matter how wide the gap looks.

Example (illustrative): a header row with three fields. In the first line, tabs are written as <TAB> so you can see them. The second line is the same row written with escape sequences, as you would type it in most programming languages.

name<TAB>city<TAB>zip
"name\tcity\tzip"

Characters that look like a tab but are not

Character | Code point | Decimal | Why it gets confused with a tab
Space | U+0020 | 32 | Editors set to insert or expand spaces can replace tabs with runs of spaces
No-break space | U+00A0 | 160 | Common in text copied from web pages and word processors
Vertical tab | U+000B | 11 | Also a tab control character (^K), but it is not a field delimiter in TSV
Em space | U+2003 | 8195 | A wide blank used in typesetting
Ideographic space | U+3000 | 12288 | A full-width blank used in CJK text

How to identify a tab by its code, step by step

  • 1. Choose a tool that shows character codes or makes control characters visible. Options for the command line, Python, JavaScript, spreadsheets and text editors follow.
  • 2. Look at the suspicious gap. A tab shows as 09 in hex, 9 in decimal, \t in escaped output, or ^I in caret notation.
  • 3. If you see 20 (32) instead, the gap is spaces. If you see c2 a0 in a UTF-8 hex dump, it is a no-break space.
  • 4. Verify across the whole file, not only one line, as described in the verification section below.

Command line (Linux and macOS)

cat -et file.tsv          # tabs shown as ^I, line ends as $ (GNU and BSD cat)
od -c file.tsv | head     # tabs shown as \t
xxd file.tsv | head       # tabs shown as byte 09
grep -c $'\t' file.tsv    # count lines containing a tab (bash, zsh, ksh)

Example (illustrative, not captured output; column spacing varies by system): piping a short string through od -c shows the tab as \t between the two words.

$ printf 'id\tname\n' | od -c
0000000   i   d  \t   n   a   m   e  \n

Python

line = "id\tname"
for ch in line:
    print(repr(ch), ord(ch), hex(ord(ch)))

# The tab prints as: '\t' 9 0x9
print("\t" in line)      # True if the line contains a tab
print(line.split("\t"))  # ['id', 'name']

JavaScript

const line = "id\tname";
line.charCodeAt(2);    // 9
line.codePointAt(2);   // 9
line.includes("\t");   // true

Spreadsheets

=CODE(MID(A1,3,1))            returns 9 if the third character of A1 is a tab
=UNICODE(MID(A1,3,1))         same check by Unicode code point
=ISNUMBER(FIND(CHAR(9),A1))   TRUE if A1 contains a tab anywhere
=SUBSTITUTE(A1,CHAR(9)," | ")  shows tabs as " | " in a helper column

Use the SUBSTITUTE formula in a separate helper column so the original cell stays unchanged.

Text editors

Many code and text editors have an option to show whitespace or invisible characters. When it is on, tabs are usually drawn as arrows and spaces as dots. Editors that support regular-expression search let you search for \t to jump to each tab. Menu names and defaults differ between editors and versions, so check your editor's documentation for the exact setting.

Verify the result without changing content

  • Check that every line has the same field count. Different counts point to a missing tab or a space where a tab should be:
  • awk -F'\t' '{print NF}' file.tsv | sort | uniq -c
  • Before saving a TSV in an editor, check settings such as "insert spaces" or "expand tabs". They usually affect what you type, but some editors also reformat whitespace on save.
  • Compare a checksum before and after any edit that should not touch delimiters, for example sha256sum file.tsv. If the checksum changed when you expected it not to, compare hex dumps to find the difference.
  • Avoid running expand on a TSV unless you intend to convert tabs into spaces. That conversion removes the delimiters.

Using the tab code as a delimiter in common tools

cut -f2 file.tsv                  # cut splits on tab by default
awk -F'\t' '{print $2}' file.tsv   # awk interprets \t itself
sort -t $'\t' -k2,2 file.tsv       # sort needs a real tab character
paste a.txt b.txt                 # joins lines with a tab by default

# Python
import csv
with open("file.tsv", newline="") as f:
    for row in csv.reader(f, delimiter="\t"):
        print(row)

Quoting matters on the command line. In bash, zsh and ksh, $'\t' produces an actual tab character. Other shells may not support this syntax. Plain single quotes, as in '\t', pass a literal backslash and t to the program. That works for awk, which interprets the escape itself, but tools such as sort expect the delimiter to be the real character.

A tab inside a field value will be read as a field boundary. There is no single escaping convention for this across tools. Some write it as the two characters \t, and others quote the field. Check how the program that produced the file handles it before you transform the data.

Limits of this guide

No tool-specific evidence was supplied for this article. The code values above are fixed by the ASCII and Unicode standards. The commands and functions reflect widely documented behavior of common GNU and BSD utilities, Python, JavaScript and spreadsheet software, but options and defaults can vary by version. The examples are illustrative and were not run to produce verified output.