RGB to Oklch Color Converter

Convert RGB to the perceptually uniform Oklch color space

Ad placeholder (leaderboard)

Convert a screen sRGB color into Oklch — the cylindrical form of the modern Oklab color space, expressed as Lightness, Chroma, and Hue. Oklch is the perceptual model recommended by CSS Color 4 because it keeps hue and lightness behaving predictably, especially across blues.

How it works

Oklab is defined by Bjorn Ottosson with two fixed matrices and a cube-root nonlinearity. RGB is converted to Oklab, then to Oklch:

  1. Gamma-expand sRGB to linear RGB (the standard sRGB transfer function).
  2. Linear RGB to LMS cone responses with the first Oklab matrix, then take the cube root of each LMS value.
  3. LMS’ to Oklab with the second matrix, giving L, a, b.
  4. Oklab to Oklch:
L = L
C = sqrt(a^2 + b^2)
H = atan2(b, a) in degrees, normalised to 0-360

Example

Convert rgb(59, 130, 246):

  • Oklab ≈ L 0.62, a −0.04, b −0.18
  • C = √(0.04² + 0.18²) ≈ 0.19
  • H ≈ 258° (blue)
  • Result: oklch(0.62 0.19 258)

Notes

Lightness is on a 0–1 scale (CSS also accepts a percentage). Grays have chroma ≈ 0 and an undefined hue, reported as 0. The conversion uses Ottosson’s exact matrices and runs entirely in your browser — nothing is uploaded.

Ad placeholder (rectangle)