Skip to main content
ansicode

SGR 38;2;R;G;B — 24-bit truecolor foreground

Pick any of 16,777,216 foreground RGB colors directly.

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x1b[38;2;R;G;Bm
\\033[\033[38;2;R;G;Bm
\\e[\e[38;2;R;G;Bm
ESC [ESC [ 3 8 ; 2 ; R ; G ; B m
hex1b 5b 33 38 3b 32 3b ... 6d

Description

R, G, B are each 0–255. Background equivalent: `\x1b[48;2;R;G;Bm`. Many parsers accept either the semicolon form (xterm/legacy) or the ECMA-48-compliant colon form `\x1b[38:2::R:G:Bm` (note the empty 4th sub-parameter for the colorspace ID). Truecolor is the right default for modern emulators; check `$COLORTERM=truecolor` or `24bit` before emitting in cross-environment tools.

Spec citation: ITU-T T.416 / xterm-ctlseqs (Direct color)

Examples

bash
printf '\033[38;2;255;128;0morange\033[0m\n'
python
print('\x1b[38;2;255;128;0morange\x1b[0m')
go
fmt.Print("\x1b[38;2;255;128;0morange\x1b[0m\n")
javascript
console.log('\x1b[38;2;255;128;0morange\x1b[0m')
c
printf("\x1b[38;2;255;128;0morange\x1b[0m\n");

Terminal support

xterm
yes
Linux console (fbcon)
no
macOS Terminal.app
partial
iTerm2
yes
Windows Terminal
yes
cmd.exe / ConPTY
partial
kitty
yes
alacritty
yes
WezTerm
yes
Ghostty
yes
GNOME Terminal
yes
Konsole
yes
tmux
no
GNU screen
no

Related sequences

In the family cookbook

SGR cookbook · 4. Truecolor — `\x1b[38;2;r;g;b m`