ANSI Basic 16 Colors - Standard and Bright Color Codes
Complete reference for the 16 basic ANSI colors including 8 standard colors (codes 0-7) and 8 bright/high-intensity colors (codes 8-15). Foreground, background, and escape sequences for each.
Detailed Explanation
The 16 Basic ANSI Colors
The original ANSI standard defines 8 base colors and 8 bright (high-intensity) variants. These 16 colors are universally supported across virtually every terminal emulator, making them the safest choice for cross-platform CLI applications.
Standard Colors (0-7)
The first 8 colors use SGR codes 30-37 for foreground and 40-47 for background:
| Code | Color | FG | BG |
|---|---|---|---|
| 0 | Black | 30 | 40 |
| 1 | Red | 31 | 41 |
| 2 | Green | 32 | 42 |
| 3 | Yellow | 33 | 43 |
| 4 | Blue | 34 | 44 |
| 5 | Magenta | 35 | 45 |
| 6 | Cyan | 36 | 46 |
| 7 | White | 37 | 47 |
Bright Colors (8-15)
Bright variants use SGR codes 90-97 for foreground and 100-107 for background:
| Code | Color | FG | BG |
|---|---|---|---|
| 8 | Bright Black | 90 | 100 |
| 9 | Bright Red | 91 | 101 |
| 10 | Bright Green | 92 | 102 |
| 11 | Bright Yellow | 93 | 103 |
| 12 | Bright Blue | 94 | 104 |
| 13 | Bright Magenta | 95 | 105 |
| 14 | Bright Cyan | 96 | 106 |
| 15 | Bright White | 97 | 107 |
Usage Example (Bash)
# Red text
echo -e "\033[31mThis is red\033[0m"
# Bright green text on blue background
echo -e "\033[92;44mBright green on blue\033[0m"
Important Notes
The actual appearance of these colors depends on the terminal's color scheme. Many terminals allow users to customize the RGB values of the 16 base colors, so "red" might appear differently across terminals. The bright variants were originally rendered by combining the bold attribute with the standard color, but modern terminals treat them as distinct colors.
Use Case
The 16 basic colors are essential for any developer creating command-line tools, shell scripts, or terminal-based applications. They are the most portable choice since every terminal from xterm to Windows Console supports them. Use them for color-coded log output, interactive prompts, status messages, and progress indicators in CLI tools.