Skip to main content
ansicode

SGR 49 — Default background color

Reset only the background color (leaves attributes + fg intact).

Byte forms

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

\\x1b[\x1b[49m
\\033[\033[49m
\\e[\e[49m
ESC [ESC [ 4 9 m
hex1b 5b 34 39 6d

Live preview

Rendered in your browser via the same tokeniser the decoder uses — no terminal needed.

red bg back to default bg

Description

ECMA-48 §8.3.117 names SGR 49 "default background colour" — the same shape as SGR 39 but acting on the background channel. Byte sequence \x1b[49m, CSI followed by 4 9 then final m. Restores the background to the theme default without touching foreground, bold, italic, underline, reverse, blink, or strikethrough. The complement of \x1b[39m (default foreground). The most common idiom is end-of-banner: a coloured row like \x1b[41;37m WARNING \x1b[49m closes with SGR 49 to drop just the red background while keeping the white foreground for whatever text follows on the same line.

Portability — universal across the same matrix that supports SGR 39 (xterm, iTerm2, kitty, alacritty, wezterm, gnome-terminal, Konsole, Ghostty, Windows Terminal, ConPTY 1809+, Linux console). Linux console honours SGR 49 — it removes the per-cell background attribute and returns the cell to the kernel's default background slot. tmux passes the byte through unmodified. terminfo does not expose SGR 49 as its own capability — op (orig pair) emits \x1b[39;49m, which folds both directions into one query. A subtle gotcha: when SGR 7 (reverse video) is active, "background" and "foreground" are visually swapped, so SGR 49 still resets what *was* originally the background channel — the layered semantics are correct but the visual effect can surprise an unprepared reader.

Like SGR 39, SGR 49 is itself the close — the default background is the close, there is no separate "default-background close." The portable "drop just the colours, keep emphasis" recipe is \x1b[39;49m (or \x1b[0m followed by re-applying any attributes you wanted to preserve — but the 39;49 pair is one round-trip cheaper and avoids re-asserting bold / italic / etc.). Be aware that on a light theme the "default background" is usually near-white, so the visual reset of \x1b[41m...\x1b[49m is dramatic; on a dark theme the default is near-black and the contrast is far more subdued, which is occasionally a surprise when the same banner code is read across two themes. Related: sgr-bg-basic (SGR 40-47, basic 8-colour background that SGR 49 closes), sgr-default-fg (SGR 39, the matching foreground reset), sgr-reset (SGR 0, full attribute reset).

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

Examples

bash
printf '\033[41;37m WARNING \033[49m text\033[0m\n'
python
print('\x1b[41mred bg\x1b[49m default bg\x1b[0m')
go
fmt.Print("\x1b[41mred bg\x1b[49m default bg\x1b[0m")
javascript
console.log('\x1b[41mred bg\x1b[49m default bg\x1b[0m')
c
printf("\x1b[41mred bg\x1b[49m default bg\x1b[0m\n");

Used in

Real-world tools that emit this sequence — anchors the bytes to commands you've already used.

  • chalk (Node) bg helpers`chalk.bgReset` resets only the background — preserves chained `.bold.red`
  • colorama (Python) Back.RESETnarrow reset for callers that swap bg per cell (table renderers)
  • deltabetween cell paints on diff hunks so the next cell starts from terminal default bg
  • tig, lazygit — table backgrounds reset between columns
  • bat highlighted line backgrounds reset between chunks

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
yes
GNU screen
yes

Related sequences

In the family cookbook

SGR cookbook · 2. 16-color basic — `\x1b[31m` and friends