The Oklch to RGB converter takes a color expressed in the perceptual Oklch space and converts it back to a standard sRGB hex code. Oklch is increasingly used in CSS because it produces smoother gradients and more uniform palettes than HSL, but you still need plain RGB or hex for many tools.
How it works
Oklch is simply Oklab written in cylindrical (polar) coordinates. The conversion proceeds in well-defined steps:
- Oklch → Oklab: keep
L, and seta = C · cos(H)andb = C · sin(H)with H in radians. - Oklab → nonlinear LMS: multiply by the inverse Oklab matrix
M2⁻¹. - Cube each LMS component to undo the cube-root used when building Oklab, giving linear LMS.
- Linear LMS → linear sRGB: multiply by the matrix
M1⁻¹. - Gamma-encode each linear channel with the sRGB transfer curve and scale to 0–255.
If any channel ends up outside 0–255, the color is outside the sRGB gamut; the tool clamps it and flags the result.
Notes
Lranges 0–1,His in degrees 0–360, andCis typically 0 to about 0.37 for the most saturated sRGB colors.- Because Oklch can reach beyond sRGB, the gamut warning tells you when the shown hex is an approximation.
All matrix math runs locally in your browser — nothing is uploaded.