OKLCH color converter
Enter two opaque CSS colors to convert them and compare text contrast. Results and swatches update as you type.
Convert opaque CSS colors and inspect their sRGB fallback.
How it works
Conversions follow CSS Color 4 sections 7, 9 and 19: decode sRGB, transform through D65 XYZ and OKLab, then use polar coordinates for OKLCH. Intermediate values stay unrounded. Display values use six decimal places; HEX uses rounded bytes.
HEX, RGB, HSL and swatches use a channel-clipped sRGB fallback. OKLab and OKLCH retain the original color. This clipping can differ from browser gamut mapping.
contrast = (lighter luminance + 0.05) / (darker luminance + 0.05)
WCAG checks use unrounded fallback channels: AA needs 4.5:1 for normal text or 3:1 for large text; AAA needs 7:1 or 4.5:1 respectively. Large means at least 18pt, or 14pt bold.
Worked examples
Black on white
#000000 against #ffffff gives 21:1 and passes all four text contrast checks.
CSS Color 4 reference
oklch(65% 0.15 270) converts to #6c88ea, matching the specification’s rounded example.
Frequently asked questions
Which input syntax is supported?
Why does the fallback look different?
What happens to gray hue?
Does a pass guarantee an accessible page?
Sources
- CSS Color 4 — color conversion and sample code (checked 2026-11-14)
- WCAG 2.2 — contrast minimum (checked 2026-11-14)
- WCAG 2.2 — contrast enhanced (checked 2026-11-14)
Last reviewed 2026-11-14. The method is written out above so you can check our math.