Terminal Color Reference
ANSI terminal color escape codes reference and preview.
Foreground Colors
| Preview | Escape Code | Code | |
|---|---|---|---|
| Black | \e[30m | FG: 30 | |
| Red | \e[31m | FG: 31 | |
| Green | \e[32m | FG: 32 | |
| Yellow | \e[33m | FG: 33 | |
| Blue | \e[34m | FG: 34 | |
| Magenta | \e[35m | FG: 35 | |
| Cyan | \e[36m | FG: 36 | |
| White | \e[37m | FG: 37 |
Bright/Bold
| Preview | Escape Code | Code | |
|---|---|---|---|
| Bright Black | \e[90m | FG: 90 | |
| Bright Red | \e[91m | FG: 91 | |
| Bright Green | \e[92m | FG: 92 | |
| Bright Yellow | \e[93m | FG: 93 | |
| Bright Blue | \e[94m | FG: 94 | |
| Bright Magenta | \e[95m | FG: 95 | |
| Bright Cyan | \e[96m | FG: 96 | |
| Bright White | \e[97m | FG: 97 |
Background Colors
| Preview | Escape Code | Code | |
|---|---|---|---|
| Black BG | \e[40m | BG: 40 | |
| Red BG | \e[41m | BG: 41 | |
| Green BG | \e[42m | BG: 42 | |
| Yellow BG | \e[43m | BG: 43 | |
| Blue BG | \e[44m | BG: 44 | |
| Magenta BG | \e[45m | BG: 45 | |
| Cyan BG | \e[46m | BG: 46 | |
| White BG | \e[47m | BG: 47 |
Text Styles
| Preview | Escape Code | Code | |
|---|---|---|---|
| Bold | \e[1m | 1 | |
| Dim | \e[2m | 2 | |
| Italic | \e[3m | 3 | |
| Underline | \e[4m | 4 | |
| Blink | \e[5m | 5 | |
| Reverse | \e[7m | 7 |
Custom Escape Code Builder
Output
\e[32mHello, World!\e[0mAbout this tool
The ANSI Terminal Color Reference is a quick lookup and live preview for the escape codes that add color and style to terminal output. Those codes are cryptic sequences that are hard to remember, so this tool turns them into something you can simply browse and see.
Scan the foreground colors, background colors, and text styles like bold and underline, watch the live preview update, and copy the exact escape sequence for whatever you want. It is handy when building CLI tools, writing shell scripts, formatting log output, or colorizing program messages.
A useful tip: combine a foreground color, a background color, and a style code, and always add a reset at the end so later text is not affected. Everything runs locally in your browser, with nothing sent to a server.
Frequently Asked Questions
Code Implementation
# ANSI terminal colors in Python
import sys
# Basic colors
RED = '\033[31m'
GREEN = '\033[32m'
YELLOW = '\033[33m'
BLUE = '\033[34m'
RESET = '\033[0m'
BOLD = '\033[1m'
print(f"{RED}Error: Something went wrong{RESET}")
print(f"{GREEN}Success: Operation completed{RESET}")
print(f"{YELLOW}Warning: Check your input{RESET}")
print(f"{BOLD}{BLUE}Info: Starting process...{RESET}")
# Cross-platform (use colorama for Windows support)
# pip install colorama
try:
from colorama import Fore, Back, Style, init
init(autoreset=True)
print(Fore.RED + 'Red text')
print(Back.GREEN + Fore.BLACK + 'Green background')
print(Style.BRIGHT + 'Bold text')
except ImportError:
# Fallback to direct ANSI codes
print('\033[31mRed text\033[0m')
Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.