Convert RGB to OKLAB instantly — get accurate L, a, b values plus HEX, RGB, and OKLCH output, no signup required.
How RGB Converts to OKLAB
Converting RGB to OKLAB happens in three stages: sRGB is linearized, transformed into LMS cone-response space, then mapped into the OKLAB coordinate system.
Step 1 — Linearize sRGB. Each RGB channel (0–255) is divided by 255, then converted from gamma-encoded sRGB to linear light using the standard sRGB transfer function.
Step 2 — Convert to LMS. The linear RGB values are multiplied through a fixed 3×3 matrix that approximates how the eye’s long, medium, and short-wavelength cone cells respond to the color.
Step 3 — Apply the cube root and final matrix. Each LMS value is cube-rooted (this is what gives OKLAB its perceptual uniformity), then multiplied through a second matrix to produce the final L (lightness), a (green–red), and b (blue–yellow) values.
The result is a color space where equal numeric steps correspond to roughly equal perceived steps — a property plain RGB and even HSL don’t have.
OKLAB vs RGB: What’s the Difference?
OKLAB and RGB represent the same colors but organize them differently. RGB stores color as three light-intensity channels (red, green, blue), which is efficient for displays but not aligned with how humans perceive brightness or color difference. OKLAB stores color as lightness (L) plus two perceptual axes (a, b), so a given numeric change produces a visually consistent change.
This matters most for gradients and color scales: interpolating directly between two RGB values often passes through muddy, uneven-looking intermediate colors, while interpolating in OKLAB produces a smooth, perceptually even transition. It’s why OKLAB (and its cylindrical form, OKLCH) has become the preferred space for generating design-system color palettes, CSS gradients, and data-visualization scales — RGB is still what your screen ultimately renders, but OKLAB is closer to how you’d naturally think about “a bit lighter” or “a bit more red.”
When to Use This Converter
- Building gradients or color palettes — get OKLAB values to plug into
oklab()oroklch()CSS for smoother, more even color transitions than RGB-based gradients - Working with the CSS Color Module Level 4 — modern browsers support
oklab()andoklch()natively, so you can copy the CSS string directly into your stylesheet - Comparing or auditing colors perceptually — L, a, b values make it easier to judge whether two colors are “close” in a way that matches human vision, not just numerically close in RGB
Frequently Asked Questions
What is OKLAB used for?
OKLAB is used to represent color in a perceptually uniform way, so equal changes in its L, a, and b values look like equal changes to the human eye. It’s commonly used for generating smooth CSS gradients, building consistent color palettes, and comparing colors more accurately than RGB or HSL allow.
Is OKLAB better than RGB for gradients?
Yes, for most gradient and color-scale work OKLAB produces smoother, more natural-looking transitions than RGB. RGB gradients can pass through dull or muddy intermediate tones because RGB isn’t perceptually uniform, while OKLAB interpolation stays visually consistent from start to end color.
How accurate is RGB to OKLAB conversion?
The conversion is mathematically exact for any valid sRGB color, since OKLAB and sRGB both describe points within the same visible color range. The one exception is converting from OKLAB back to RGB: some OKLAB values fall outside what sRGB displays can reproduce, in which case the result is clipped to the nearest displayable RGB color.
