Identify the backspace Unicode control character

How to recognize the backspace control character (U+0008), what it changes in stored text versus display, and when to remove or replace it.

What the backspace character is

The backspace control character is U+0008, a C0 control code inherited from ASCII, where it has byte value 8 (hexadecimal 08). Unicode classifies it as general category Cc (control). Like the other C0 controls, it has no ordinary character name in the Unicode Character Database. Its formal name aliases are BACKSPACE and the abbreviation BS. It also has no glyph of its own. It is an instruction intended for a device or program, not a symbol meant to be drawn.

Property | Value
Code point | U+0008
Decimal / hexadecimal | 8 / 0x08
UTF-8 encoding | single byte 08
UTF-16 code unit | 0008
General category | Cc (Control)
Name aliases | BACKSPACE, BS
Caret notation | ^H (typed as Ctrl+H in many terminals)
Common escapes | \b (C, JSON and many languages), \x08, \u0008

What it actually changes

A backspace changes the stored text by adding one code point. It does not remove the preceding character from the data. Any visible effect comes from the program that displays the text. A terminal emulator typically moves the cursor one position to the left, so the next printed character overwrites the previous one. Browsers and many graphical text fields do not carry out that instruction. They may ignore the character, show a placeholder box, or display nothing at all. As a result, the same stored string can look different from one place to another. That difference comes from presentation, not from the stored characters.

$ printf 'cat\br\n'
car

$ printf 'cat\br\n' | od -c
0000000   c   a   t  \b   r  \n
0000006

In the example, the terminal shows "car" because the cursor stepped back over the t and the r was printed in its place. The dump shows that the stored bytes are still c, a, t, backspace, r. Software that reads the bytes sees five visible-intent characters plus a control code, not the word "car".

The same mechanism enabled overstriking on printers and terminals. Printing a character, a backspace and an underscore produced underlining. Printing a character, a backspace and the same character again produced bold. Formatted manual page output still uses this convention, and pagers convert it into bold or underlined display.

Terms like "reverse", "mirror" or "font" do not describe backspace. It does not reorder, flip or restyle text. It also differs from the Backspace key. In a graphical editor, pressing that key deletes text directly and inserts no character. In a terminal, the key may send BS (^H) or DEL (U+007F), depending on configuration such as the stty erase setting. A U+0008 found in a file therefore often comes from captured terminal output, logs, legacy systems or a bug, not from someone editing normally.

Characters that are easy to confuse with it

Character | Code point | What it is
BACKSPACE (BS) | U+0008 | Invisible control instruction
DELETE (DEL) | U+007F | A different control code; some terminals send it for the Backspace key
SYMBOL FOR BACKSPACE (␈) | U+2408 | Visible graphic from the Control Pictures block, used to depict BS
ERASE TO THE LEFT (⌫) | U+232B | Visible symbol commonly used to label backspace keys
SYMBOL FOR DELETE (␡) | U+2421 | Visible graphic depicting DEL
\b in regular expressions | none | Usually a word-boundary assertion, not the backspace character

How to spot and identify it

Several clues suggest a hidden backspace. A string's length may exceed its visible characters. A search may fail on a word that looks correct. Terminal output may differ from the same content opened in an editor. A parser may report an unexpected control character. To confirm, inspect code points rather than rendered text. Helpful search terms include "U+0008", "backspace control character", "BS control code", "^H", "show invisible characters" and "control pictures".

  • Hex dump (xxd or hexdump): the byte appears as 08.
  • od -c: the byte appears as \b.
  • cat -v: the byte appears as ^H.
  • Python: repr() shows '\x08', and ord() returns 8.
  • JavaScript: JSON.stringify() shows \b, and charCodeAt() returns 8.
  • Regular expressions: match it with \x08, or with [\b] inside a character class in engines such as Python, JavaScript and PCRE. Outside a class, \b usually means word boundary.
$ printf 'pass\bword' | xxd
00000000: 7061 7373 0877 6f72 64                   pass.word

>>> repr('pass\bword')
"'pass\\x08word'"

Many editors have options for showing invisible or control characters, but the names and menu locations vary. No specific editor setting was verified for this article, so check your editor's documentation for its exact control.

Will it survive copying and sharing?

Not reliably. Depending on the environment, clipboards, web forms and messaging services may keep the character invisibly, strip it or replace it. No tests of specific destinations were supplied, so confirm the behavior in the environment you actually use. Several formats, however, document clear rules.

  • JSON: control characters U+0000 to U+001F must be escaped inside strings. \b is a valid escape, and a raw unescaped backspace makes the JSON invalid.
  • XML 1.0: U+0008 is not a permitted character, even as a character reference. XML 1.1 allows it only as a character reference.
  • HTML: control characters other than whitespace are parse errors, and how browsers display them varies.
  • Search and editing: a backspace inside a word breaks exact matching, adds to string length and can make cursor movement inconsistent with what is visible.

Accessibility behavior is an open question. No documentation or tests were supplied that show how particular screen readers announce, skip or ignore U+0008. Text that depends on backspace to look right, such as overstruck output, should not be treated as accessible until it has been converted to plain text.

Should you keep it, remove it or replace it?

Keep a raw U+0008 only where a program is designed to interpret it, such as terminal control streams, legacy protocols or overstrike-formatted output sent to a pager. In documentation, web pages, data files, messages and anything people will read or search, plain text is the better choice. The main benefit of identifying the character is that it explains otherwise invisible mismatches. The key tradeoff is between keeping the raw bytes and preserving the intended meaning.

  • For the intended result, write what the reader should see (for example, "car" rather than c-a-t-backspace-r). col -b does this for overstruck manual page output.
  • For technical documentation, write an escape or code point notation such as \b, \x08 or U+0008.
  • For a visible marker, use ␈ (U+2408). It is a real printable character, not a working control.
  • For debugging or forensics, keep an untouched copy of the original before cleaning.

Removing backspaces is not the same as applying them. Deleting every U+0008 with a command such as tr -d '\b' turns c-a-t-backspace-r into "catr", which matches neither the stored intent nor the terminal display. Choose deletion only when the backspaces are noise. When they encode overwrites that matter to the meaning, choose a tool that applies them.