ANSI 256 Color Picker
Browse all 256 terminal colours with index and RGB value.
Overview
The ANSI 256 Color Picker lets you browse every entry in the xterm 256-color palette and copy its numeric index alongside the matching sRGB hex code. Each swatch shows the index used by \x1b[38;5;Nm escape sequences, so you can drop colours straight into a shell prompt, log formatter, or TUI without guessing.
Useful for developers building terminal applications, customising shell themes, generating ANSI escape codes for CLI output, or matching a brand colour to the closest 8-bit terminal slot that ships on every modern emulator.
How it works
The 256-color palette is split into three regions: indices 0–15 are the legacy system colours (often remapped by the terminal theme), 16–231 form a 6×6×6 RGB cube where each channel uses six perceptually-spaced steps (0, 95, 135, 175, 215, 255), and 232–255 are a 24-step greyscale ramp. The picker computes the canonical sRGB value for each index using those exact step tables.
Because terminals can override the first 16 entries, the cube and greyscale regions are the only ones with guaranteed reproducibility. For best portability, choose an index in the 16–255 range when emitting ANSI escapes from scripts.
Examples
Index 196 → #ff0000 (\x1b[38;5;196m bright red)
Index 21 → #0000ff (cube blue)
Index 244 → #808080 (greyscale mid)
Index 208 → #ff8700 (cube orange)
FAQ
How do I print one of these colours in bash?
Use printf '\e[38;5;%dm%s\e[0m\n' 208 'hello' for foreground, or 48;5 for background. The index comes straight from the table.
Why does index 1 look different on my machine?
The first 16 slots are themeable. macOS Terminal, Windows Terminal, iTerm2 and tmux all let users remap them, so a "red" of 1 may appear teal under a custom scheme.
Are the RGB values exact?
For cube and greyscale indices, yes — they follow the xterm specification exactly. System colours (0–15) are emulator-defined and only the conventional defaults are shown.
Can I convert from arbitrary hex to a 256 index?
The closest match is found by snapping each RGB channel to the nearest cube step, then comparing the result against the greyscale ramp and picking whichever has the smaller perceptual distance.
Does 256-color mode work over SSH?
Yes, provided TERM is set to xterm-256color or similar on both ends. Truecolor (24-bit) requires COLORTERM=truecolor instead.