Skip to main content

Standard ANSI colors

AI-Generated Content
This page was generated with the assistance of AI and may contain inaccuracies. It is intended as a placeholder for future human verification. If you spot issues ahead of its initial review, please report them on GitHub!
Standard

Standard ANSI colors use SGR parameters to set the foreground and background to one of 8 normal or 8 bright colors.

Syntax​

CSI 30-37 m       SGR — Set foreground to standard color
CSI 39 m SGR — Reset foreground to default
CSI 40-47 m SGR — Set background to standard color
CSI 49 m SGR — Reset background to default
CSI 90-97 m SGR — Set foreground to bright color
CSI 100-107 m SGR — Set background to bright color
Formal syntax
SGR-fg-color      = 0x1b, "[", fg-code, "m" ;
SGR-bg-color      = 0x1b, "[", bg-code, "m" ;
SGR-fg-bright     = 0x1b, "[", fg-bright-code, "m" ;
SGR-bg-bright     = 0x1b, "[", bg-bright-code, "m" ;
SGR-fg-default    = 0x1b, "[", "39", "m" ;
SGR-bg-default    = 0x1b, "[", "49", "m" ;
fg-code           = "30" | "31" | "32" | "33" | "34" | "35" | "36" | "37" ;
bg-code           = "40" | "41" | "42" | "43" | "44" | "45" | "46" | "47" ;
fg-bright-code    = "90" | "91" | "92" | "93" | "94" | "95" | "96" | "97" ;
bg-bright-code    = "100" | "101" | "102" | "103" | "104" | "105" | "106" | "107" ;

Parameters​

Foreground colors (30-37):

CodeColor
30Black
31Red
32Green
33Yellow
34Blue
35Magenta
36Cyan
37White
39Default foreground

Background colors (40-47):

CodeColor
40-47Same colors as 30-37
49Default background

Bright colors (90-97, 100-107):

The bright/intense color variants. Codes 90-97 set bright foreground; 100-107 set bright background.

Description​

Per ECMA-48 §8.3.117, SGR parameters 30-37 set the foreground display color and 40-47 set the background color. ECMA-48 defines these as: black (30/40), red (31/41), green (32/42), yellow (33/43), blue (34/44), magenta (35/45), cyan (36/46), and white (37/47).

The bright color ranges (90-97 for foreground, 100-107 for background) are not part of ECMA-48 but are a widely supported extension originally from AIXTerm. They provide access to the "bright" or "intense" versions of the 8 standard colors without requiring the bold attribute.

SGR 39 and 49 reset the foreground and background to their default colors respectively. SGR 0 resets all colors and attributes.

The actual RGB values for these colors are not standardized and vary between terminals. Most terminals allow users to customize them.

Examples​

printf '\e[31mRed text\e[0m\n'
printf '\e[32;43mGreen on yellow\e[0m\n'
printf '\e[91mBright red text\e[0m\n'
printf '\e[97;104mBright white on bright blue\e[0m\n'

Specifications​

SpecificationSection
XTerm ctlseqs—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✓YesSGR 30-37, 40-47, 90-97, 100-107 listed in escape_support.md
Bobcat??Implemented in external TerminalCtrl library, not in Bobcat source code
contour✓v0.1.0
foot✓YesSGR 30-37, 40-47, 90-97, 100-107 in csi.c:153-311
Ghostty✓v1.0.0
iTerm2✓v20260216-nightly
Kitty✓YesPresent since early versions
Konsole✓YesFull support for SGR 30-37, 40-47, 90-97, 100-107 in src/Vt102Emulation.cpp:2064-2110
mintty✓YesSGR 30-37, 40-47, 90-97, 100-107 fully implemented at termout.c:2195-2265
mlterm✓rel-2_9_1
PuTTY✓0.43SGR 30-37, 40-47, 90-97, 100-107 fully supported since initial release
Rio✓v0.0.3
rxvt-unicode✓rxvt-unicode-1.2
st✓0.4
terminology✓v0.1.0
VT100✗No
VTE✓YesSGR 30-37, 40-47, 90-97, 100-107 all handled in parser-sgr.hh
WezTerm✓YesFull support for SGR 30-37, 40-47, 90-97, 100-107 - see wezterm-escape-parser/src/csi.rs:2775-2950
Windows Terminal✓YesSGR 30-37, 40-47, 90-97, 100-107 fully implemented in adaptDispatchGraphics.cpp
xterm✓YesSGR 30-37, 40-47 documented as VT100. SGR 90-97, 100-107 require OPT_AIX_COLORS compile flag
xterm.js✓0.3
Multiplexers
cy✓Yes
GNU Screen✓v.4.2.0Requires COLOR compile flag
tmux✓0.8
tuios✓v0.0.15
Zellij✓v0.12.0

See also​