Color to Websafe Value Converter
Convert any color to its nearest websafe (216 colors) or websmart (4096 colors) equivalent. Shows HEX, RGB, HSL with perceptual distance.
About
The websafe palette contains exactly 216 colors formed by restricting each RGB channel to multiples of 51 (0x33). This constraint dates to 8-bit display adapters that could only render 256 indexed colors, of which 40 were reserved by operating systems. Selecting a color outside this set caused dithering artifacts on those displays. The websmart palette relaxes the step to 17 (0x11), yielding 4096 colors expressible as doubled-nibble hex codes (e.g., #1188CC). Modern browsers render 24-bit color, but websafe values remain relevant in constrained environments: email clients, embedded firmware displays, low-bandwidth SVG optimizations, and accessibility overlays where palette restriction reduces cognitive load. This tool quantizes any input color to both palettes and reports the perceptual shift using CIE76 ΔE so you can judge whether the substitution is visually acceptable. A ΔE below 2.3 is generally imperceptible; above 5, most observers notice the difference.
Formulas
Each RGB channel is quantized independently. For a channel value c and quantization step s, the nearest quantized value q is:
For websafe, s = 51. For websmart, s = 17. The result is clamped to [0, 255].
Perceptual color distance uses CIE76 ΔE in CIELAB space:
where L, a, b are obtained by converting RGB → XYZ (D65 illuminant) → CIELAB. A ΔE < 1.0 is imperceptible; ΔE > 5.0 indicates a clearly visible shift.
Where c = input channel value (0 - 255), s = quantization step, q = quantized output, L = lightness, a = green-red axis, b = blue-yellow axis.
Reference Data
| Channel Value (Dec) | Hex | Websafe | Websmart | Step 51 Nearest | Step 17 Nearest |
|---|---|---|---|---|---|
| 0 | 00 | ✓ | ✓ | 0 | 0 |
| 17 | 11 | ✗ | ✓ | 0 | 17 |
| 34 | 22 | ✗ | ✓ | 51 | 34 |
| 51 | 33 | ✓ | ✓ | 51 | 51 |
| 68 | 44 | ✗ | ✓ | 51 | 68 |
| 85 | 55 | ✗ | ✓ | 102 | 85 |
| 102 | 66 | ✓ | ✓ | 102 | 102 |
| 119 | 77 | ✗ | ✓ | 102 | 119 |
| 136 | 88 | ✗ | ✓ | 153 | 136 |
| 153 | 99 | ✓ | ✓ | 153 | 153 |
| 170 | AA | ✗ | ✓ | 153 | 170 |
| 187 | BB | ✗ | ✓ | 204 | 187 |
| 204 | CC | ✓ | ✓ | 204 | 204 |
| 221 | DD | ✗ | ✓ | 204 | 221 |
| 238 | EE | ✗ | ✓ | 255 | 238 |
| 255 | FF | ✓ | ✓ | 255 | 255 |
| Websafe valid values per channel: 00, 33, 66, 99, CC, FF (6 values → 63 = 216 colors) | |||||
| Websmart valid values per channel: 00, 11, 22 … FF (16 values → 163 = 4096 colors) | |||||