RGB to OKLab Converter
RGB in, OKLab out — with the working shown.
To convert RGB to OKLab, normalise the input, linearise the channels, move into the perceptual space, then check the gamut. For example, rgb(47 129 247) in RGB is oklab(61.82% -0.0391 -0.1895) in OKLab.
This is a free RGB to OKLab converter. Type or paste any red, green and blue channel values into the field above and the OKLab value updates as you type, along with every other notation the web understands. OKLab is a modern perceptual space with noticeably better hue linearity than CIE Lab.
Conversions run entirely in your browser using the same color engine as the rest of the site: values round-trip through linear sRGB and CIE XYZ rather than through an approximation, so what you copy is accurate to the last digit the format can carry.
How to convert RGB to OKLab
- Normalise the input. Read the RGB value and scale each component into the 0–1 range the maths expects.
- Linearise the channels. Undo the sRGB gamma curve, because the encoded 0–255 numbers are not proportional to light and averaging them directly is what makes gradients go muddy.
- Move into the perceptual space. Convert linear RGB into LMS cone responses, take the cube root, and apply the OKLab matrix.
- Check the gamut. Clamp anything that falls outside what an sRGB display can show, so the value you copy is the value you get.
Worked example: rgb(47 129 247) converts to oklab(61.82% -0.0391 -0.1895). That color is Dodger Blue, and the tool above shows each intermediate step for whatever value you enter.
Common RGB to OKLab values
The twenty colors people look up most often, converted from RGB to OKLab. Every row is computed by the same engine as the tool above.
| Color | RGB | OKLab |
|---|---|---|
| White | rgb(255 255 255) | oklab(100% 0 0) |
| Black | rgb(0 0 0) | oklab(0% 0 0) |
| Red | rgb(255 0 0) | oklab(62.8% 0.2249 0.1258) |
| Lime | rgb(0 255 0) | oklab(86.64% -0.2339 0.1795) |
| Blue | rgb(0 0 255) | oklab(45.2% -0.0325 -0.3115) |
| Yellow | rgb(255 255 0) | oklab(96.8% -0.0714 0.1986) |
| Cyan | rgb(0 255 255) | oklab(90.54% -0.1494 -0.0394) |
| Magenta | rgb(255 0 255) | oklab(70.17% 0.2746 -0.1692) |
| Silver | rgb(192 192 192) | oklab(80.78% 0 0) |
| Gray | rgb(128 128 128) | oklab(59.99% 0 0) |
| Maroon | rgb(128 0 0) | oklab(37.67% 0.1349 0.0755) |
| Olive | rgb(128 128 0) | oklab(58.07% -0.0428 0.1191) |
| Green | rgb(0 128 0) | oklab(51.98% -0.1403 0.1077) |
| Purple | rgb(128 0 128) | oklab(42.09% 0.1647 -0.1015) |
| Teal | rgb(0 128 128) | oklab(54.31% -0.0896 -0.0236) |
| Navy | rgb(0 0 128) | oklab(27.11% -0.0195 -0.1869) |
| Orange | rgb(255 165 0) | oklab(79.27% 0.0566 0.1614) |
| Pink | rgb(255 192 203) | oklab(86.77% 0.073 0.0091) |
| Gold | rgb(255 215 0) | oklab(88.68% -0.0169 0.1814) |
| Crimson | rgb(220 20 60) | oklab(57.12% 0.2084 0.0762) |
RGB and OKLab, briefly
RGB is three channels from 0 to 255 describing how hard the display drives its red, green and blue subpixels. Valid range: 0–255 per channel.
OKLab is a modern perceptual space with noticeably better hue linearity than CIE Lab. Valid range: L 0–1, a and b roughly −0.4 to 0.4.
OKLCH is worth learning if you have not. Unlike HSL, equal steps of its lightness channel look equal to the eye, which is what makes generated ramps and hover states behave predictably across every hue.
Frequently asked questions
How do you convert RGB to OKLab?
1. Read the RGB value and scale each component into the 0–1 range the maths expects. 2. Undo the sRGB gamma curve, because the encoded 0–255 numbers are not proportional to light and averaging them directly is what makes gradients go muddy. 3. Convert linear RGB into LMS cone responses, take the cube root, and apply the OKLab matrix. 4. Clamp anything that falls outside what an sRGB display can show, so the value you copy is the value you get. The converter on this page does all of it as you type, and shows the working underneath.
What is rgb(255 0 0) in OKLab?
Pure red, rgb(255 0 0), is oklab(62.8% 0.2249 0.1258) in OKLab. There is a table of twenty common colors converted to OKLab further up this page.
What is rgb(47 129 247) in OKLab?
rgb(47 129 247) converts to oklab(61.82% -0.0391 -0.1895). It is a dodger blue, and you can paste any other value into the field at the top of the page to convert it.
Is RGB to OKLab conversion lossless?
Within sRGB, yes — converting to OKLab and back returns the value you started with. The only rounding happens when a component is written out to a fixed number of decimal places.
Can I use OKLab directly in CSS?
Yes. oklab(61.82% -0.0391 -0.1895) is valid CSS and works in every current browser. It is the modern choice, because it can also express colors outside sRGB on wide-gamut displays.
Does this RGB to OKLab converter support transparency?
Alpha is preserved wherever the target notation can carry it — eight-digit hex, rgb() / a, hsl() / a and the modern CSS spaces all round-trip an alpha channel. CMYK has no alpha, so it is dropped there.
Is my color data sent anywhere?
No. Every conversion on this site runs in your browser with no network request, no account and no analytics. You can disconnect and it keeps working.