Color Studio & WCAG Contrast Checker
A color studio and WCAG contrast checker is a web accessibility utility that converts between color formats (HEX, RGB, HSL, HSV, OKLCH) and calculates the exact relative luminance contrast ratio between foreground text and background elements to certify compliance with W3C Web Content Accessibility Guidelines (WCAG 2.1/2.2 AA and AAA).
W3C Relative Luminance & Contrast Ratio Equations
L = 0.2126 \times R_{lin} + 0.7152 \times G_{lin} + 0.0722 \times B_{lin} \quad | \quad \text{Ratio} = \frac{L_1 + 0.05}{L_2 + 0.05}
Relative luminance L is computed after linearizing sRGB gamma. The contrast ratio compares the lighter color L1 against darker color L2 with an ambient 0.05 offset.
How to Use This Tool
- Select or Paste Any Color Code: Input HEX (#6366f1), RGB (rgb(99, 102, 241)), HSL, or modern perceptual OKLCH.
- Check WCAG Accessibility Compliance: Evaluates standard body text, large text (18pt+), and UI components against white and dark backgrounds.
- Generate Harmonic Palettes: Explore complementary, triadic, and monochromatic harmonies to assemble accessible color palettes.
Worked Example
Scenario: Test an indigo button (#4F46E5) with white text (#FFFFFF).
Calculation: White L1 = 1.000, Indigo L2 = 0.117. Ratio = (1.000 + 0.05) / (0.117 + 0.05) = 1.05 / 0.167
Result: Contrast Ratio = 6.29:1 (Passes WCAG AA for normal text, Passes AAA for large text)
Common Mistakes & Pitfalls to Avoid
- Assuming colors that look readable on high-end monitors are accessible to all users. Always verify mathematical contrast scores. Low-contrast gray text on white backgrounds fails accessibility standards for users with vision impairments or on screens in bright sunlight.
- Evaluating contrast without considering font size and weight. Large text (18pt / 24px regular or 14pt / 18.5px bold) only requires 3:1 contrast for AA, whereas normal body copy requires at least 4.5:1.
Frequently Asked Questions
- What are the WCAG 2.1 AA and AAA contrast requirements?
- WCAG AA requires a minimum ratio of 4.5:1 for standard text and 3:1 for large text. The enhanced AAA standard requires 7:1 for normal text and 4.5:1 for large text.
- Why is OKLCH preferred in modern CSS?
- OKLCH is a perceptually uniform color space that aligns with human visual perception. Changing hue in OKLCH does not cause unintended shifts in perceived brightness, unlike HSL.