Five ways to write one color
HEX and RGB are the same three numbers for red, green and blue, once in base 16 and once in decimal. HSL rearranges those sRGB values into hue, saturation and lightness, which is easier to adjust by hand, but its lightness does not match what the eye sees: yellow and blue at 50% lightness look very different.
OKLab and OKLCH, published by Björn Ottosson in 2020, are built so that equal steps look like equal changes. OKLCH describes a color by lightness (L), chroma (C, how colorful) and hue (h, an angle from 0 to 360). Both are part of CSS Color Module Level 4, written as oklab() and oklch().
How the conversion works
Each sRGB channel is divided by 255 and converted to linear light. Ottosson’s first matrix turns linear RGB into cone responses, which are cube-rooted, and his second matrix gives OKLab. OKLCH is OKLab in polar form: chroma is the distance from grey and hue is the angle.
Going back runs the same steps in reverse. If an OKLCH or OKLab color lands outside sRGB, this tool lowers its chroma until it fits, keeping lightness and hue, and says so.
#1f6feb → R 31, G 111, B 235 ÷ 255, linearized → 0.0137, 0.1590, 0.8308 OKLab → L 0.5686, a −0.0363, b −0.1990 C = √(a² + b²) = 0.2023 h = atan2(b, a) = 259.67° → oklch(56.86% 0.202 259.67)
OKLCH in design systems
Because OKLCH lightness tracks what people see, it makes tint and shade scales predictable: keep chroma and hue, step the lightness, and every step looks evenly spaced. The same works for building a dark theme from a light one.
OKLCH can describe colors that sRGB cannot, such as the more saturated colors of Display P3 screens. Keep a HEX or rgb() fallback for anything that has to look the same everywhere, and hand colors to developers in the format the codebase already uses.
- Adjust lightness in OKLCH rather than HSL when you need a lighter or darker version of a brand color
- Check text and background pairs with a contrast checker after changing lightness
- Write the source value next to converted ones in a style guide, so rounding never drifts across handovers