Skip to main content
ansicode

SGR 39 — Default foreground color

Reset only the foreground color (leaves attributes + bg intact).

Byte forms

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

\\x1b[\x1b[39m
\\033[\033[39m
\\e[\e[39m
ESC [ESC [ 3 9 m
hex1b 5b 33 39 6d

Description

Resets the foreground to the terminal's theme default without disturbing the background, bold/italic/underline, or other SGR state. The complement of `\x1b[49m` (default background). Useful when you want to switch fg colors mid-line without emitting a full SGR 0 reset and re-applying every attribute.

Spec citation: ECMA-48 §8.3.117 (SGR parameter 39)

Examples

bash
printf '\033[1;31mERROR\033[39m bold continues\033[0m\n'
python
print('\x1b[31mred\x1b[39m default\x1b[0m')
go
fmt.Print("\x1b[31mred\x1b[39m default\x1b[0m")
javascript
console.log('\x1b[31mred\x1b[39m default\x1b[0m')
c
printf("\x1b[31mred\x1b[39m default\x1b[0m\n");

Terminal support

xterm
yes
Linux console (fbcon)
yes
macOS Terminal.app
yes
iTerm2
yes
Windows Terminal
yes
cmd.exe / ConPTY
yes
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 · 2. 16-color basic — `\x1b[31m` and friends