Skip to content

256-color fg (SGR 38;5)

Category: sgr · Baseline: modern · Tags: Xterm Extensions · Specification ↗

ESC [ 38;5;N m
SGR 38;5;N sets the foreground to one of 256 colors. The sequence is ESC [ 38;5;N m where N is 0-255. Colors 0-7 are the standard colors, 8-15 are bright, 16-231 are a 6x6x6 color cube, and 232-255 are a grayscale ramp. This palette provides a reasonable range of colors that works across most modern terminals without requiring truecolor support.
How this is testedautomated
Send \x1b[38;5;196mX (256-color red), verify the foreground red channel > 200.

The same probe runs against headless backends (via Termless) and real terminal apps (via a daemon launched in each terminal). This lets us distinguish parser correctness from rendering correctness.

Analysis2026-04-06

Supported by 11 of 12 terminals (92%). Not supported by: vt100.js. Part of the Modern TUI baseline. Notes: vt100.js: Not in VT100/VT220 — only 8 standard colors supported.

Supported by 12 of 14 backends (86%)

Terminal Applications

TerminalVersionSupportNotes
iTerm23.6.9✓ yes
Ghostty1.3.1✓ yes
VS Code✓ yes
Warp✓ yes
Cursor✓ yes
Terminal.app✓ yes

Headless Backends

Parser correctness only — a means the parser accepts the sequence.

BackendVersionSupportNotes
Alacritty0.26.0✓ yes
Kitty0.40.0✓ yes
vterm0.2.0✓ yes
xterm.js5.5.0✓ yes
WezTerm0.1.0-fork.5~ partialBackend returns palette index instead of resolved RGB
vt100.js0.2.1✗ noNot in VT100/VT220 — only 8 standard colors supported