📊 RGB to OKLCH Converter
Convert rgb() values into oklch(), the perceptually uniform format, with OKLAB, LAB and HEX shown alongside.
#1d87f1
oklch(62.3% 0.1828 253.6)oklab(62.3% -0.0517 -0.1753)lab(56.02 10.09 -61.05)lch(56.02 61.88 279.4)hwb(210 11% 5%)#1d87f1rgb(29, 135, 241)hsl(210, 88%, 53%)Exact OKLab matrices (Björn Ottosson) + CIE XYZ/LAB (D65). Out-of-gamut OKLCH colors are chroma-mapped along constant L and H. 🔒 Computed in your browser.
How the rgb to oklch converter works
Each RGB channel is linearised from sRGB (undoing the gamma curve so the numbers are proportional to light), passed through the LMS cone-response step and the exact OKLab matrices, then converted to polar form, chroma C = √(a² + b²) and hue H = atan2(b, a), and written as oklch(L% C H). The page also shows OKLAB, CIELAB, LCH, HWB and the HEX form of the same color, so you can copy whichever your CSS needs.
RGB and OKLCH describe the same color, but OKLCH separates lightness from hue and chroma perceptually, so once in OKLCH you can lighten or shift hue without the muddiness that RGB and HSL edits produce.
Frequently asked questions
How do I convert RGB to OKLCH?
Enter the red, green and blue values (0-255); the tool linearises them and applies the OKLab transform to give an oklch() value, plus OKLAB and LAB.
Is RGB to OKLCH exact?
Yes. It uses the published OKLab matrices, so the result matches the oklch() a browser computes from the same RGB color.
Why use OKLCH instead of RGB?
RGB is how screens emit color but is not intuitive to edit; OKLCH is perceptually uniform, so lightness and hue adjustments look even. It is the modern CSS authoring format.
Does it show a HEX version too?
Yes, the HEX equivalent is shown next to the OKLCH, OKLAB and LAB values.
Why linearise the RGB channels first?
sRGB values are gamma-encoded, so they are not directly proportional to light intensity. Linearising undoes that curve, which is required before the OKLab matrices, which assume linear light, can be applied. Skipping it would give wrong lightness and hue.
Is every RGB colour representable in OKLCH?
Yes, every sRGB (and therefore every RGB or HEX) colour has an exact OKLCH value, so RGB to OKLCH is lossless. Gamut trouble only appears in the reverse direction, when an OKLCH colour is too vivid for an sRGB screen to display.
Is my color uploaded?
No, every conversion runs in your browser.