How to Identify the ASCII Tab Character

Learn how to identify the ASCII tab character (code 9, hex 09, U+0009) in text, tell it apart from spaces, and confirm it with common inspection commands.

A tab and a run of spaces can look identical on screen, but they are different characters. That difference matters in data files, source code, configuration files and anything parsed by a program. This guide explains what the ASCII tab is, how inspection tools reveal it, and how to check your text without accidentally changing it.

What the ASCII tab character is

The ASCII tab, formally called horizontal tab (HT), is a control character. It has no visible glyph. When text is displayed, it moves the cursor to the next tab stop, so its on-screen width depends on the editor or terminal settings. A single tab may look like two, four or eight spaces even though it is stored as one character.

Property | Value
Name in ASCII | Horizontal Tab (HT)
Name in Unicode | CHARACTER TABULATION
Decimal code | 9
Hexadecimal code | 09
Unicode code point | U+0009
Common escape sequence | \t
Caret notation | ^I
Keyboard control equivalent | Ctrl+I

The ASCII tab should not be confused with the vertical tab (VT), which is a separate control character at decimal 11, hex 0B, U+000B. When people say "tab" in everyday text work, they almost always mean the horizontal tab at code 9.

What an inspection tool does for your text

An invisible-character inspector takes plain text as input and shows what each character actually is, instead of how it renders. For tabs, the output is a visible marker such as \t, ^I, an arrow symbol, the hex value 09 or the code point U+0009 at the position where the tab occurs. Read-only inspection does not modify the text; it only reveals it. Conversion features, such as replacing tabs with spaces, are a separate step and do change the content.

The scope that matters for identifying a tab: the tool must report the exact character, not a normalized version of it. If a tool trims whitespace, collapses spaces or converts tabs before displaying them, it cannot tell you whether the original contained a tab.

Step-by-step: confirm whether text contains a tab

  • 1. Work on a copy of the text or file, so any accidental edit does not affect the original.
  • 2. Use an inspection method that shows raw characters (see the options below).
  • 3. Look for the tab marker at the suspected position: \t, ^I, 09 or U+0009.
  • 4. If you see 20 (hex) or U+0020 instead, those positions are ordinary spaces, not tabs.
  • 5. If you see A0 or U+00A0, that is a non-breaking space, another invisible character that is not a tab.
  • 6. Record the positions of any tabs before deciding whether to keep, remove or convert them.

Command-line methods

The commands below are widely available on Linux and macOS shells. The sample input is created with printf so that the tab is written explicitly as \t rather than typed invisibly. The outputs shown are illustrative of the documented display format and were not captured from a test run for this article; exact spacing can vary between implementations.

# Create a sample containing: a, TAB, b, newline
printf 'a\tb\n' > sample.txt

# Show tabs as ^I and line ends as $ (GNU cat)
cat -A sample.txt
# Example output:
# a^Ib$

# Show each byte as a character or escape
od -c sample.txt
# Example output:
# 0000000   a  \t   b  \n
# 0000004

# Show bytes in hex
od -An -tx1 sample.txt
# Example output:
#  61 09 62 0a

In the hex view, 09 is the tab, 61 is the letter a, 62 is b and 0a is the newline. On some systems cat -A is not supported; cat -t or cat -vt is the usual alternative for showing tabs as ^I.

Finding lines that contain a tab

# Bash and similar shells: $'\t' passes a real tab to grep
grep -n $'\t' sample.txt

# GNU grep with Perl-compatible patterns
grep -nP '\t' sample.txt

Both commands print matching lines with their line numbers. A plain pattern such as grep '\t' without these forms may be interpreted as a backslash followed by t, depending on the grep version, so it is not a reliable tab search.

Methods in code

Programming languages can report the character code directly, which removes any doubt about what you are looking at. The results noted in the comments follow from the definition of the tab as code 9; they are examples, not captured output.

# Python
text = 'a\tb'
print(repr(text))           # shows 'a\tb'
print(ord(text[1]))         # 9
print('\t' in text)         # True
print([hex(ord(c)) for c in text])  # ['0x61', '0x9', '0x62']

// JavaScript
const text = 'a\tb';
console.log(text.charCodeAt(1));                // 9
console.log(text.includes('\t'));               // true
console.log(JSON.stringify(text));              // "a\tb"

Printing the raw string with print or console.log will render the tab as blank space. Use repr in Python or JSON.stringify in JavaScript when you need the tab shown as \t.

Methods in text editors

Most code editors have an option to render whitespace, often named something like Show Whitespace, Show Invisibles or Render Whitespace. When enabled, tabs typically appear as an arrow or a line, and spaces as small dots. Many editors also let you search with regular expressions, where \t matches a tab. The exact menu names and symbols differ between editors, and the supplied material did not document any specific editor, so check your editor's settings for the equivalent option.

Avoiding unintended changes

Tabs are often meaningful. In tab-separated values (TSV) files, each tab marks a column boundary, and Makefiles require recipe lines to begin with a tab. Replacing tabs with spaces in those cases can break the file. Before converting, keep these points in mind:

  • Copying text from a web page, chat or word processor can silently turn tabs into spaces, so inspect the original file rather than a pasted copy when possible.
  • Editor settings such as "insert spaces for tab" or automatic reformatting on save can rewrite tabs without an obvious prompt.
  • Tools like expand (tabs to spaces) and unexpand (spaces to tabs) modify content; run them on a copy and compare the result.
  • After any conversion, re-run a byte-level check such as od -c to confirm exactly what changed.

Quick reference

What you see | What it means
\t | Horizontal tab (code 9)
^I | Horizontal tab in caret notation
09 (hex) | Horizontal tab byte
U+0009 | Horizontal tab code point
20 (hex) or U+0020 | Ordinary space
A0 or U+00A0 | Non-breaking space, not a tab
0B (hex) or U+000B | Vertical tab, a different control character

Gaps in this guide

No tool-specific evidence was supplied for this article, so it does not compare named online inspectors or describe their interfaces, limits or output formats. The character codes and command behaviors described here are standard, generally documented facts, but command options and display spacing can differ across operating systems and tool versions. Verify against your own system's documentation.