ANSI Escape Codes

Reference for ANSI terminal escape sequences — cursor, erase, mode and more.

Searchable ANSI/VT100 escape sequence reference covering CSI cursor moves, erase commands, SGR text modes, screen buffer and OSC sequences, with copyable literal bytes and examples.

What is the ESC character in an ANSI sequence?

ESC is the escape control character, decimal 27 or hex 0x1B. Most ANSI sequences start with ESC followed by '[' to form a Control Sequence Introducer (CSI). In code it is often written as \e, \033 or \x1b.

Control the terminal with escape sequences

ANSI (also called VT100) escape sequences are short byte strings that tell a terminal to move the cursor, clear regions, change text style, switch screen buffers, or set the window title. They all start with the ESC control character. This reference groups the common sequences by purpose and lets you copy each one with the real ESC byte already in place.

How it works

Almost every sequence here is a Control Sequence Introducer: the bytes ESC [ followed by optional numeric parameters and a final letter that selects the action. For example ESC[{row};{col}H positions the cursor, where {row} and {col} are 1-based numbers you supply. SGR (Select Graphic Rendition) sequences like ESC[1m (bold) and ESC[0m (reset) change text appearance. OSC sequences begin with ESC ] and handle window titles and hyperlinks. When you copy, the \e placeholder is replaced with the actual ESC byte (0x1B).

Tips and examples

  • Clear the screen and home the cursor with ESC[2J then ESC[H.
  • Wrap colored output in ESC[0m at the end so later text is not stained.
  • In bash use ANSI-C quoting: printf '\e[1mBold\e[0m\n'.
  • {n} and {row};{col} are parameters you fill in; omitting a number usually defaults it to 1.
  • OSC 8 hyperlinks let you embed clickable links in supporting terminals without showing the raw URL.