ASCII·ESC
27
ESC
0x1B · 0011011

ASCII 27 — the ESC character

Not a visible character

ESC is control code 27, hex 1B. You type it as ^[, and write it short as \e.

Characters that draw nothing and instead tell the device to do something.

What this control code did

Escape

Others · Deleting, cancelling, and ESC — the key that opens a second meaning.

Seven bits

ASCII is seven bits wide, which is why there are 128 of them. The eighth bit was long left for parity.

0011011

One bit — the sixth, worth 32 — separates the cases. Off gives a capital, on gives a lowercase letter.

Kind
Control
Decimal
27
Hexadecimal
0x1B
Octal
033
Binary
0011011
HTML entity

URL encoding
%1B
CSS escape
\1B
Short escape
\e
Ctrl key
^[

Only \e is missing from standard C; GCC, shells and regex engines take it.

The chart

Eight columns for the top three bits, sixteen rows for the bottom four. The capitals column sits right beside the lowercase one — that is the shape of the table.

Codes either side

How to read this

  • Add 32 to a capital and you get the lowercase letter — one bit flips.
  • Digits start at 48, so subtracting 48 from the code gives the number.
  • Holding Ctrl clears the top three bits — that is why Ctrl+I is a tab.
  • Everything under 32, plus 127, draws nothing. Those show their abbreviation instead.

Frequently asked questions

Q. What is the ASCII code for ESC?

Decimal 27, hex 1B, octal 033, binary 0011011.

Q. How do I write ESC in HTML?

As .

Q. How does it go in a URL?

It is encoded as %1B.

Q. How do I type ESC?

^[. In a string you write it \e.