Color Visualizer
Interactive color visualizer with real-time conversion between HEX, RGB, HSL, HSV, CMYK, and LAB. Generate harmonies, check WCAG contrast, and simulate color blindness.
About
Incorrect color specification causes cascading failures: a hex value off by one digit shifts hue by up to 16 steps, CMYK-to-RGB mismatches produce print output that deviates from screen by 15 - 30% in perceived saturation, and WCAG contrast violations below the 4.5:1 ratio threshold render text illegible for roughly 8% of male users with color vision deficiency. This tool computes bidirectional conversions across six color spaces (sRGB, HSL, HSV, CMYK, CIE LAB, HEX) using the D65 standard illuminant and CIE 1931 observer functions. It approximates CMYK output assuming an idealized ICC profile without ink-density correction. Contrast ratios follow WCAG 2.1 relative luminance: L = 0.2126R + 0.7152G + 0.0722B after gamma linearization.
Color blindness simulation uses the Brettel-Viénot-Mollon transformation matrices for dichromatic vision. Note: simulated output is an approximation. Actual perception varies by severity (anomalous trichromacy vs. full dichromacy) and individual physiology. Pro Tip: always validate critical UI colors against both Protanopia and Deuteranopia simultaneously, as red-green deficiency accounts for over 99% of inherited color vision deficiency cases.
Formulas
RGB to HSL conversion maps Cartesian color coordinates into cylindrical form. Given normalized channels R′, G′, B′ ∈ [0, 1]:
Cmin = min(R′, G′, B′)
Δ = Cmax − Cmin
L = Cmax + Cmin2
S =
Where Cmax is the maximum channel value, Δ is the chroma range, L is lightness (midpoint of max and min), and S is saturation relative to lightness.
WCAG 2.1 contrast ratio between two colors uses relative luminance:
CR = L1 + 0.05L2 + 0.05
Where Rlin is the linearized sRGB channel: if C ≤ 0.04045, then Clin = C ÷ 12.92; otherwise Clin = ((C + 0.055) ÷ 1.055)2.4. L1 is the lighter luminance and L2 the darker.
RGB to CIE LAB requires an intermediate XYZ transform using the D65 illuminant reference white (Xn = 0.95047, Yn = 1.0, Zn = 1.08883):
a* = 500 ⋅ (f(X ÷ Xn) − f(Y ÷ Yn))
b* = 200 ⋅ (f(Y ÷ Yn) − f(Z ÷ Zn))
Where f(t) = t1/3 if t > 0.008856, else f(t) = 7.787t + 16116.
Reference Data
| Color Space | Components | Range | Primary Use | Perceptually Uniform |
|---|---|---|---|---|
| sRGB | R, G, B | 0 - 255 | Screen display, CSS, Web | No |
| HEX | 6-digit base-16 | #000000 - #FFFFFF | Web shorthand for RGB | No |
| HSL | H, S, L | 0 - 360°, 0 - 100% | CSS color functions, design | No |
| HSV/HSB | H, S, V | 0 - 360°, 0 - 100% | Photoshop, color pickers | No |
| CMYK | C, M, Y, K | 0 - 100% | Print (subtractive mixing) | No |
| CIE LAB | L*, a*, b* | L: 0 - 100, a/b: ±128 | Perceptual color difference | Yes (approx.) |
| CIE XYZ | X, Y, Z | 0 - 1 (normalized) | Intermediate conversion space | No |
| WCAG Luminance | L | 0 - 1 | Contrast ratio calculation | Linearized sRGB |
| WCAG 2.1 Contrast Requirements | ||||
| AA Normal Text | ≥ 4.5:1 | Body text < 18pt or < 14pt bold | ||
| AA Large Text | ≥ 3.0:1 | Text ≥ 18pt or ≥ 14pt bold | ||
| AAA Normal Text | ≥ 7.0:1 | Enhanced accessibility | ||
| AAA Large Text | ≥ 4.5:1 | Enhanced accessibility, large text | ||
| Color Vision Deficiency Prevalence | ||||
| Protanopia | 1.0% males | Missing L-cone (red) | ||
| Deuteranopia | 1.0% males | Missing M-cone (green) | ||
| Tritanopia | 0.003% | Missing S-cone (blue) | ||
| Protanomaly | 1.1% males | Shifted L-cone sensitivity | ||
| Deuteranomaly | 4.6% males | Shifted M-cone sensitivity (most common) | ||
| Achromatopsia | 0.003% | Complete color blindness, rod monochromacy | ||
| Named CSS Color Constants (Selection) | ||||
| Coral | #FF7F50 | rgb(255, 127, 80) | ||
| SlateBlue | #6A5ACD | rgb(106, 90, 205) | ||
| MediumSeaGreen | #3CB371 | rgb(60, 179, 113) | ||
| GoldenRod | #DAA520 | rgb(218, 165, 32) | ||
| Tomato | #FF6347 | rgb(255, 99, 71) | ||