Developer Tools
ANSI Color Code Generator
Build and decode ANSI escape codes for terminal colors. 16, 256, and truecolor with bold, italic, underline. Copy snippets for bash, Python, Node, PowerShell.
ANSI color code generator
Pick colors and styles, type the text you want to colorize, then copy the snippet for your terminal or language.
Live preview
Terminal
Hello, world!
Followed by ESC[0m, so styling does not bleed into the next line.
SGR parameters
ESC[31m
Foreground color
Background color
The terminal default color will be used. Useful when you only want to apply a style or a background.
Text styles
Multiple styles combine in a single sequence: ESC[1;3;4m means bold, italic, and underline together.
Output snippets
Every snippet ends with ESC[0m so the next line resets cleanly.
Raw escape sequence
The actual ESC bytes. Use in files or pipes.
[31mHello, world![0m
String literal (hex \x1b)
Drop into any language that accepts \x1b escapes.
\x1b[31mHello, world!\x1b[0m
String literal (octal \033)
Older bash and many C codebases prefer octal.
\033[31mHello, world!\033[0m
Bash (echo -e)
Requires the -e flag so the shell interprets \x1b.
echo -e "\\x1b[31mHello, world!\\x1b[0m"
Bash (printf %b)
More portable than echo -e. Works in dash, busybox, and zsh.
printf '%b\n' '\033[31mHello, world!\033[0m'
Python
print() interprets \x1b in normal string literals.
print("\\x1b[31mHello, world!\\x1b[0m")Node.js / JavaScript
Standard double-quoted string. Works in any modern terminal.
console.log("\\x1b[31mHello, world!\\x1b[0m");PowerShell
Uses $([char]27) because backtick-e requires PS 6 or newer.
Write-Host "$([char]27)[31mHello, world!$([char]27)[0m"
C / C++ string literal
Pass to printf, write, or fputs with stdout / stderr.
"\\x1b[31mHello, world!\\x1b[0m"
Standard 16-color palette
The widely supported subset. SGR codes 30 to 37 and 90 to 97 for foreground, 40 to 47 and 100 to 107 for background.
| Color | Fg | Bg | Preview |
|---|---|---|---|
| Black | 30 | 40 | |
| Red | 31 | 41 | |
| Green | 32 | 42 | |
| Yellow | 33 | 43 | |
| Blue | 34 | 44 | |
| Magenta | 35 | 45 | |
| Cyan | 36 | 46 | |
| White | 37 | 47 | |
| Bright Black (Gray) | 90 | 100 | |
| Bright Red | 91 | 101 | |
| Bright Green | 92 | 102 | |
| Bright Yellow | 93 | 103 | |
| Bright Blue | 94 | 104 | |
| Bright Magenta | 95 | 105 | |
| Bright Cyan | 96 | 106 | |
| Bright White | 97 | 107 |
SGR style codes
The single-byte attribute parameters. Not every terminal honors blink or italic.
- 0ResetClear every style and color.
- 1BoldBrighten and embolden text.
- 2DimFaint / reduced intensity.
- 3ItalicItalic text (terminal-dependent).
- 4UnderlineSingle underline.
- 5BlinkSlow blink (often disabled).
- 7ReverseSwap foreground and background.
- 8ConcealHide text without removing it.
- 9StrikethroughLine through the text.
How to use
- Type the text you want to colorize into the Sample text field. The live preview at the bottom of the card updates as you type.
- Pick a foreground color: choose Default to leave the terminal default, 16 colors for the most portable palette, 256 palette for any xterm index, or RGB / Truecolor for any 24-bit color.
- Optionally pick a background color the same way, then toggle any text styles you want (bold, italic, underline, blink, reverse, strikethrough).
- Read the live preview and the SGR parameters card to confirm the sequence is right.
- Copy a snippet that matches your environment: bash echo, bash printf, Python, Node.js, PowerShell, or the raw escape sequence. Every snippet ends with ESC[0m so the next line resets cleanly.
- Switch to Decoder mode to paste an existing ANSI string and see every segment and parameter explained in plain English.
About this tool
ANSI Color Code Generator builds and decodes the ESC[ ... m escape sequences that color terminal output across bash, zsh, fish, PowerShell, Python, Node.js, Ruby, Go, and any other language that writes to a TTY. Pick a foreground color and a background color from three palettes: the widely supported 16 named colors (SGR 30 to 37 and 40 to 47, plus the bright variants 90 to 97 and 100 to 107), the xterm 256-color palette (38;5;N and 48;5;N with the standard 0..15 names, the 6x6x6 RGB cube at 16..231, and the 24-step grayscale ramp at 232..255), or 24-bit truecolor (38;2;R;G;B and 48;2;R;G;B) for any RGB value. Stack on text styles using the standard SGR parameters: bold (1), dim (2), italic (3), underline (4), blink (5), reverse (7), and strikethrough (9). The live preview renders the result with the same color and style attributes a typical terminal would apply, including the reverse-video swap and the dim opacity, so you can see what the output will look like before pasting it into your script. The output panel emits ready-to-paste snippets in every common shape: the raw escape sequence (real ESC bytes for use in files or pipes), string literals using either the \x1b hex form or the \033 octal form, a bash echo -e command, a portable bash printf '%b' command (works in dash, busybox, and zsh), a Python print() call, a Node.js console.log() call, a PowerShell Write-Host using $([char]27) so it works in Windows PowerShell 5.1 as well as PowerShell 7, and a C / C++ string literal you can pass to printf or fputs. Every snippet ends with the explicit reset sequence ESC[0m so styling does not bleed into the next line of output. The Decoder mode takes any ANSI string you paste (real ESC bytes, the \x1b escape, the \033 octal form, the \e form, the \u001b form, or the literal ESC[ prefix) and breaks it into segments, explains every SGR parameter in plain English, names the foreground and background colors, expands 38;5;N and 38;2;R;G;B into their human description, and surfaces any non-SGR CSI sequences (cursor movement, clear screen, save / restore) that were ignored. Useful for adding colored output to a CLI tool, generating banners for a build script, writing readable log levels in a deploy pipeline, decoding the byte stream a Docker container is producing, learning what every parameter in an escape sequence actually means, or building a quick reference for the SGR codes when reading source from a tool like ls, grep, or git. Composition, decoding, and snippet generation all run locally in your browser. Nothing is uploaded.
Free to use. Works in your browser. No signup, no login.
Related tools
You may also like
ASCII Table
Searchable ASCII reference plus a two-way text-to-code converter.
Open tool
DeveloperHTML Entity Encoder Decoder
Two-way HTML entity encoder and decoder with named, decimal, and hex modes.
Open tool
ConverterColor Format Converter
Convert any CSS color to HEX, RGB, HSL, HWB, CMYK, and named values at once.
Open tool
DeveloperBase64 Encoder Decoder
Encode and decode Base64 with full Unicode.
Open tool
DeveloperURL Encoder Decoder
Encode and decode percent-encoded URLs.
Open tool