ANSI Escape Reference

Searchable cheatsheet of ANSI / CSI terminal codes.

Open tool

Overview

A searchable cheat sheet for ANSI escape sequences - the control codes that tint your terminal output, move the cursor, clear the screen, and toggle text attributes like bold and underline. Filter by category (SGR colours, cursor movement, screen erase, mode set/reset) or search by code, name, or effect.

This is for anyone writing CLI tools, TUI applications, prompt themes, or shell scripts that need richer output than plain text. Reach for it when you're hand-rolling escape sequences, debugging a misbehaving terminal animation, or porting code between platforms with different ANSI support.

How it works

The reference is keyed against ECMA-48 (the standard that became ANSI X3.64) - the spec defines Control Sequence Introducer (CSI) sequences as ESC [ followed by parameters and a final byte. Common subsets include SGR (Select Graphic Rendition, parameter m) for colours and attributes, cursor positioning (H, A, B, C, D), and erasing (J, K).

Modern terminals layer extensions on top - 256-colour palettes (38;5;N), 24-bit true colour (38;2;R;G;B), and OSC sequences for window titles - all included with notes on which terminals support them.

Examples

  • Red foreground text, then reset:
    \x1b[31mError\x1b[0m
    
  • Bold, underlined cyan:
    \x1b[1;4;36mNote\x1b[0m
    
  • 24-bit true colour (orange):
    \x1b[38;2;255;165;0mwarning\x1b[0m
    
  • Move cursor to row 5, column 10 then clear to end of line:
    \x1b[5;10H\x1b[K
    

FAQ

Why doesn't \x1b[31m work in my output?

Your runtime may be escaping the literal characters. In Bash use printf '\033[31mhi\033[0m\n' or echo -e. In Node, the byte is ''. In PowerShell 7+, use `e.

What's the difference between \x1b, \033, and \e?

They're all the same byte (0x1B, the ESC character) written in different notations - hex, octal, and the C escape shorthand.

Are these supported on Windows?

Modern Windows Terminal, PowerShell 7, and recent cmd.exe versions support ANSI when virtual terminal processing is enabled (it's on by default in Windows 10 1607+).

Why do I see literal [31m in my logs?

Either ANSI processing is disabled, or the output is piped to a non-TTY. Most CLIs detect this with isatty() and strip escapes; you may need a --color=always flag.

Try ANSI Escape Reference

An unhandled error has occurred. Reload ×