Color your terminal output
ANSI SGR (Select Graphic Rendition) sequences set text color in the terminal. There are three tiers: the classic 16-color palette, the 256-color (8-bit) cube, and 24-bit truecolor for any RGB value. This tool previews each color and gives you the exact escape sequence to copy, with the ESC byte already inserted.
How it works
For the 16-color set, foreground codes are 30-37 (standard) and 90-97 (bright);
background codes are 40-47 and 100-107. The 256-color palette is built from a
formula: indices 0-15 are the base colors, 16-231 form a 6x6x6 RGB cube where
each channel maps through the levels 0, 95, 135, 175, 215, 255, and 232-255 are
a grayscale ramp. The preview reproduces that math so the swatch matches a typical
terminal. Truecolor uses ESC[38;2;r;g;bm, embedding the exact red, green and
blue bytes you enter.
Tips and notes
- Foreground uses the
38selector, background uses48, both followed by;5;nfor 256-color or;2;r;g;bfor truecolor. - Always end colored runs with
ESC[0mso the color does not bleed into later output. - Bright colors (90-97) are a convenient shortcut for bold-looking text without
the
1mbold attribute. - If your terminal only supports 256 colors, pick the nearest cube index rather than truecolor.