Skip to main content
ansicode

SGR 48;2;R;G;B — 24-bit truecolor background

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

Byte forms

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

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

Description

Background sibling of `\x1b[38;2;R;G;Bm`. R, G, B are each 0–255. The ECMA-48-compliant colon form `\x1b[48:2::R:G:Bm` (empty 4th sub-parameter = colorspace ID) is accepted alongside the more common semicolon form. Check `$COLORTERM=truecolor` (or `24bit`) before emitting in cross-environment tools — terminals lacking truecolor will quantize to 256-color, which may or may not look acceptable.

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

Examples

bash
printf '\033[48;2;30;30;30;38;2;255;200;0m on graphite \033[0m\n'
python
print('\x1b[48;2;30;30;30m bg \x1b[0m')
go
fmt.Print("\x1b[48;2;30;30;30m bg \x1b[0m")
javascript
console.log('\x1b[48;2;30;30;30m bg \x1b[0m')
c
printf("\x1b[48;2;30;30;30m bg \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`