ANSI Color Codes & Terminal Formatter
Interactive ANSI escape sequence generator for terminal styling, 16/256/TrueColor palettes, and code snippets — entirely on this device.
Live Terminal Preview
Export Code Snippets
Do it offline:$
How to use it
- Enter sample text to preview inside the simulated terminal output window.
- Select your desired color depth: Standard 16 colors (4-bit), 256 colors (8-bit index), or 24-bit TrueColor (RGB).
- Toggle text styles and modifiers (Bold, Dim, Italic, Underline, Blink, Reverse, or Strikethrough).
- Customize foreground and background color swatches or type hexadecimal RGB values.
- Copy raw octal (\033[...m) or hex (\x1b[...m) escape sequences or language-specific print snippets.
Interactive ANSI escape sequence generator and cheatsheet for terminal text styling. Preview 16-color, 256-color, and 24-bit TrueColor palettes with export snippets for Bash, Python, Node.js, and Go.
How it works
Terminal emulators parse Select Graphic Rendition (SGR) escape sequences starting with ESC (\033 or \x1b) followed by '[' and parameter codes ending in 'm'.
Standard colors use codes 30-37 (foreground) and 40-47 (background), with bright variants at 90-97 and 100-107.
Extended 256-color modes use \033[38;5;{index}m for foreground and \033[48;5;{index}m for background.
24-bit TrueColor escape sequences use \033[38;2;{r};{g};{b}m and are supported by modern terminal emulators including iTerm2, Alacritty, Kitty, Windows Terminal, and VS Code terminal.
Always terminate styled terminal text with the SGR reset sequence (\033[0m) to avoid leaking colors into the user's subsequent shell prompt.
Examples
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
Common errors
FAQ
What is the difference between \033, \x1b, and \e?
All three refer to the same ASCII Escape character (decimal 27). \033 represents octal notation commonly used in Bash and C printf; \x1b represents hexadecimal notation preferred in JavaScript, Go, and Python; \e is a non-standard GNU/Bash shorthand.
Why does echo -e need the -e flag for ANSI colors?
In Bash and sh, the echo command prints backslashes literally by default. Passing the -e flag instructs echo to interpret backslash escape sequences such as \033 and \n.
Do all terminals support 24-bit TrueColor?
Most modern terminals (Windows Terminal, iTerm2, Kitty, Alacritty, GNOME Terminal) support TrueColor. Older terminals or minimal serial consoles only support 16 or 256 colors. You can check $COLORTERM in your environment for 'truecolor' or '24bit'.