How to Convert LCH to OKLCH
Converting LCH to OKLCH is the ultimate refinement of web color. Both formats use the exact same cylindrical model (Lightness, Chroma, Hue), but OKLCH is built on modern, flawless perceptual math.
LCH vs. OKLCH
LCH is based on the CIELAB color space, which was standardized in 1976. While it was a massive leap forward for perceptual color, it has a known bug: the "blue shift." When you create a gradient from blue to white in LCH, the transition often turns purple.
OKLCH is based on the OKLab color space, introduced in 2020. It uses LMS cone responses to perfectly model human vision. OKLCH fixes the blue shift, ensuring that gradients and color mixing are perfectly smooth and hue-stable.
The Conversion Process
Because they use different underlying mathematical models, you cannot simply copy the LCH values over to OKLCH. The color must pass through a complex pipeline:
- LCH to Linear RGB: The LCH values are converted to CIELAB, then to CIE XYZ, and finally to Linear sRGB.
- Linear RGB to OKLab: The linear light is processed through LMS cone response matrices to generate OKLab
L,a, andbcoordinates. - OKLab to OKLCH: Trigonometry is used to convert the
aandbcoordinates into the new Chroma and Hue values for OKLCH.