RGB to OKLab Converter

Converted OKLab Output --
100%

Wide-Gamut & Linear Formats

Modern CSS color space notations derived from this color

Contrast Analysis (WCAG 2.1)

Checks the converted color against foreground or background targets for accessibility compliance.

How to Convert RGB to OKLab

Converting RGB to OKLab brings your colors into one of the most modern and mathematically flawless color spaces available in CSS today. OKLab was designed to fix the perceptual bugs found in older spaces like CIELAB, making it the premier choice for color mixing and gradients.

What Makes OKLab Special?

Like CIELAB, OKLab uses three axes: L for Lightness, a for green/red, and b for blue/yellow. However, OKLab was built from the ground up using LMS (Long, Medium, Short) cone responses, which perfectly model how the human eye actually processes light.

The biggest flaw in older color spaces is the "blue shift." When you create a gradient from blue to white in RGB or CIELAB, the middle of the gradient often turns an ugly, muddy purple. OKLab completely eliminates this hue shift, ensuring that colors transition smoothly and naturally.

The Conversion Math

Converting RGB to OKLab requires a specific set of matrix multiplications:

  1. The RGB values are converted to linear light (removing the sRGB gamma curve).
  2. The linear RGB is multiplied by a 3x3 matrix to convert it into LMS cone space.
  3. A non-linear cube-root function is applied to the LMS values to simulate human perceptual response.
  4. A final 3x3 matrix multiplication converts the perceptual LMS values into the L, a, and b axes of OKLab.

Related Tools