How HEX, RGB, HSL & CMYK Color Models and WCAG Contrast Work
Choosing the Right Color Model for Web UI vs. Print Design
Digital screens and printed materials produce colors using fundamentally different physics. Screens emit light using the additive RGB (Red, Green, Blue) model, where each channel ranges from 0 to 255—and web developers write those three byte values in base-16 hexadecimal notation as a 6-digit HEX code (such as #2563EB). Designers prefer HSL (Hue, Saturation, Lightness) when building UI themes because adjusting Lightness creates consistent hover states and dark-mode palettes without shifting the underlying hue. Conversely, commercial printing presses mix subtractive CMYK (Cyan, Magenta, Yellow, Key/Black) inks on paper, making RGB-to-CMYK conversion essential before sending brochures or business cards to press.
How to Pick & Convert Colors in 3 Easy Steps
- Select or Paste Any Color: Click the color wheel swatch, type any 3-digit or 6-digit HEX code (e.g.,
#FF5733), or click + Pick Color from Image to sample pixels directly from a logo or screenshot. - Copy Converted Formats: Copy clean
HEX,rgb(),hsl(),cmyk(), or CSS variable snippets with one click. - Verify Accessibility & Harmonies: Check the WCAG 2.1 contrast ratio against white and black text, or click any generated tint, shade, or complementary swatch.
RGB-to-HEX & WCAG Contrast Ratio Formulas + Worked Example
Each two-character pair in a 6-digit HEX code converts a decimal RGB channel (0–255) into hexadecimal (00–FF):
Worked Example: Suppose a brand primary blue has RGB values R = 37, G = 99, B = 235.
Converting each channel to base-16: 37 = 2×16 + 5 → 25, 99 = 6×16 + 3 → 63, and 235 = 14×16 + 11 → EB, giving #2563EB.
Against pure white text (#FFFFFF, luminance 1.0), this blue achieves a 5.17:1 contrast ratio—passing WCAG 2.1 Level AA (minimum 4.5:1) for accessible body text and buttons.