Convert hex codes to OKLCH for modern CSS and Tailwind v4, with RGB, HSL and CMYK values alongside.
Enter a valid Hex value, like #3B82F6
It takes four steps. The hex code is turned into RGB, then into linear light, then into the OKLab color space, then into polar form:
1. #3B82F6 → rgb(59, 130, 246)
2. Remove the sRGB gamma curve
3. Multiply into OKLab: L, a, b
4. C = √(a² + b²), H = atan2(b, a)For #3B82F6, Tailwind v3's blue-500, that gives oklch(62.3% 0.188 259.8). Values are rounded to one decimal for L and H and three for C, which is more precise than anyone can see.
| Color | Hex | OKLCH |
|---|---|---|
| White | #FFFFFF | oklch(100% 0 0) |
| Black | #000000 | oklch(0% 0 0) |
| Red | #FF0000 | oklch(62.8% 0.258 29.2) |
| Orange | #FFA500 | oklch(79.3% 0.171 70.7) |
| Yellow | #FFFF00 | oklch(96.8% 0.211 109.8) |
| Green | #008000 | oklch(52% 0.177 142.5) |
| Blue | #0000FF | oklch(45.2% 0.313 264.1) |
| Purple | #800080 | oklch(42.1% 0.193 328.4) |
| Pink | #FFC0CB | oklch(86.8% 0.074 7.1) |
| Gray | #808080 | oklch(60% 0 0) |
Paste the hex code above and the OKLCH value appears instantly, ready to paste into CSS. The hex goes through linear RGB and the OKLab color space, then lightness, chroma and hue are read from that.
L is lightness from 0% (black) to 100% (white). C is chroma, how colorful it is, from 0 (gray) to about 0.37 at most. H is the hue angle from 0 to 360.
OKLCH lightness matches how bright a color looks. In HSL, yellow and blue at 50% lightness look very different. In OKLCH they look about the same, which makes color scales and accessible contrast easier to get right.
Yes. Tailwind CSS v4 defines its whole default palette in OKLCH, so converting brand colors to OKLCH keeps them consistent with the rest of a v4 theme.
Yes, every current version of Chrome, Safari, Firefox and Edge supports oklch(). For very old browsers, keep a hex fallback above it.