Skip to main content
ansicode

SGR 0 — Reset / Normal

Clear all text attributes and colors back to the terminal default.

Byte forms

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

\\x1b[\x1b[0m
\\033[\033[0m
\\e[\e[0m
ESC [ESC [ 0 m
hex1b 5b 30 6d

Description

`SGR 0` (Select Graphic Rendition with parameter 0) resets every text attribute the terminal is currently tracking — foreground color, background color, bold, italic, underline, reverse video, blink, etc. It is equivalent to `\x1b[m` (the parameter defaults to 0 when omitted). Always emit this at the end of styled output so the next line of text is not 'colored by leak'.

Spec citation: ECMA-48 §8.3.117 (SGR)

Examples

bash
printf '\033[31merror\033[0m\n'
python
print('\x1b[31merror\x1b[0m')
go
fmt.Print("\x1b[31merror\x1b[0m")
javascript
process.stdout.write('\x1b[31merror\x1b[0m\n')
c
printf("\x1b[31merror\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 · 1. One-shot reset — `\x1b[0m`