Standard ANSI colors
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
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):
| Code | Color |
|---|---|
30 | Black |
31 | Red |
32 | Green |
33 | Yellow |
34 | Blue |
35 | Magenta |
36 | Cyan |
37 | White |
39 | Default foreground |
Background colors (40-47):
| Code | Color |
|---|---|
40-47 | Same colors as 30-37 |
49 | Default 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
| Specification | Section |
|---|---|
| XTerm ctlseqs | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | Yes | SGR 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 | ✓ | Yes | SGR 30-37, 40-47, 90-97, 100-107 in csi.c:153-311 |
| Ghostty | ✓ | v1.0.0 | |
| iTerm2 | ✓ | v20260216-nightly | |
| Kitty | ✓ | Yes | Present since early versions |
| Konsole | ✓ | Yes | Full support for SGR 30-37, 40-47, 90-97, 100-107 in src/Vt102Emulation.cpp:2064-2110 |
| mintty | ✓ | Yes | SGR 30-37, 40-47, 90-97, 100-107 fully implemented at termout.c:2195-2265 |
| mlterm | ✓ | rel-2_9_1 | |
| PuTTY | ✓ | 0.43 | SGR 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 | ✓ | Yes | SGR 30-37, 40-47, 90-97, 100-107 all handled in parser-sgr.hh |
| WezTerm | ✓ | Yes | Full support for SGR 30-37, 40-47, 90-97, 100-107 - see wezterm-escape-parser/src/csi.rs:2775-2950 |
| Windows Terminal | ✓ | Yes | SGR 30-37, 40-47, 90-97, 100-107 fully implemented in adaptDispatchGraphics.cpp |
| xterm | ✓ | Yes | SGR 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.0 | Requires COLOR compile flag |
| tmux | ✓ | 0.8 | |
| tuios | ✓ | v0.0.15 | |
| Zellij | ✓ | v0.12.0 | |
See also
- 256-color indexed — Extended 256-color palette
- 24-bit truecolor (semicolons) — RGB color support