RGB to Oklab Color Converter

Convert RGB to the Oklab perceptually uniform color space

Ad placeholder (leaderboard)

Convert sRGB colors to Oklab

Oklab is a perceptually uniform color space designed for image processing and modern CSS. Unlike RGB or HSL, a fixed step in Oklab corresponds to a roughly equal change in how a color looks, which makes it the right tool for smooth gradients, accessible lightness tweaks, and predictable color interpolation. This converter takes any sRGB or hex color and returns its Oklab coordinates plus copy-ready CSS.

How it works

The conversion runs in three stages. First each sRGB channel is linearized: values at or below 0.04045 are divided by 12.92, and the rest follow ((c + 0.055) / 1.055) ^ 2.4. The resulting linear RGB is multiplied by a 3x3 matrix into a cone-response space (an LMS approximation), and each of those three values is passed through a cube root. A second 3x3 matrix then maps the cube-rooted values into the final L, a, and b coordinates. The polar oklch() form is derived with C = sqrt(a^2 + b^2) and H = atan2(b, a).

Example and tips

The sRGB blue #3b82f6 converts to roughly oklab(61.9% -0.026 -0.171). Because the a and b axes are unbounded, in-gamut sRGB colors usually keep them between about -0.4 and 0.4. When authoring gradients, interpolate in Oklab or oklch rather than sRGB to avoid the dark, desaturated midpoints that plague HSL blends. For hand-editing, oklch is friendlier: nudge the hue number to rotate around the color wheel without touching lightness.

Ad placeholder (rectangle)