Skip to content
ZeroServer.tools

ANSI Color Codes Reference

Complete reference for ANSI escape codes — 16 standard colors, 256-color palette, RGB true color, and text styles.

Text styles

NameEnableResetPreview
Reset\e[0mSample
Bold\e[1m\e[22mSample
Dim\e[2m\e[22mSample
Italic\e[3m\e[23mSample
Underline\e[4m\e[24mSample
Reverse\e[7m\e[27mSample
Strikethrough\e[9m\e[29mSample

Click a row to copy the escape sequence.

Standard 16 colors — foreground / background

ColorSwatchFG codeBG code
Black
Red
Green
Yellow/Brown
Blue
Magenta
Cyan
White
Bright Black (Gray)
Bright Red
Bright Green
Bright Yellow
Bright Blue
Bright Magenta
Bright Cyan
Bright White

256-color mode

Use \e[38;5;<n>m for foreground and \e[48;5;<n>m for background, where n is 0–255.

0–15

Standard 16 colors (same as above)

16–231

6×6×6 RGB color cube

232–255

24 grayscale shades (dark → light)

Click any swatch to copy its foreground escape sequence.

True color (24-bit RGB)

Use \e[38;2;R;G;Bm for foreground and \e[48;2;R;G;Bm for background.

\e[38;2;255;165;0mOrange RGB\e[0m
\e[48;2;0;100;200mBlue bg\e[0m

Common examples

Red text

\e[31mRed text\e[0m

Bold + green

\e[1;32mBold Green\e[0m

White on blue

\e[97;44mWhite on Blue\e[0m

256-color fg (orange)

\e[38;5;208mOrange\e[0m

256-color bg (purple)

\e[48;5;129mPurple bg\e[0m

True color fg

\e[38;2;255;165;0mOrange RGB\e[0m

How ANSI escape codes work

ANSI escape codes are byte sequences recognized by most terminals (Linux, macOS, Windows Terminal) to format output — colours, bold, italic, underline. The format is ESC[<code>m where ESC is the escape character (byte 0x1B, written as \e in bash/zsh or \033 in C). Always reset with \e[0m after coloured output to avoid leaking styles.

For a quick way to add color to shell scripts, see Bash Color Codes. To encode binary data, use the Base64 Encoder.

Private & free — this tool runs entirely in your browser.

Recommended: IndieKit Ship your Next.js startup in days.affiliate

Related Developer Utilities tools