What are HEX and OKLCH?
HEX writes the red, green and blue channels of sRGB as two hexadecimal digits each, from 00 to FF. OKLCH is the polar form of the Oklab space (2020): perceived lightness, chroma and hue. Equal steps of L look equally lighter, which HSL does not do, and it can reach colors outside sRGB.
Teams moving a design system to OKLCH convert their HEX tokens first, then build shades by changing only L, which keeps contrast steps predictable.
The color converter below starts from HEX and highlights OKLCH, next to HWB, LAB, LCH and CSS names.
HEX vs OKLCH
| HEX | OKLCH | |
|---|---|---|
| Notation | #RRGGBB, #RGB, #RRGGBBAA | oklch(80.9% 0.163 74.6) |
| In CSS | all browsers | Chrome 111+, Safari 15.4+, Firefox 113+ |
| Typical use | CSS, design handoff, brand guides | design systems, accessible palettes, wide-gamut screens |
Formula
Split the six digits in pairs and read each pair as a base-16 number: FF = 15 × 16 + 15 = 255, B2 = 11 × 16 + 2 = 178, 24 = 2 × 16 + 4 = 36, so #FFB224 is rgb(255, 178, 36). A three-digit HEX doubles each digit (#F80 = #FF8800). Then: sRGB channels are linearized (gamma removed), mixed into the LMS cone space, cube-rooted and mixed again into Oklab L, a, b (Björn Ottosson, 2020); OKLCH is the polar form: C = √(a² + b²) and h = atan2(b, a). Going back, a color outside sRGB is clipped to the nearest displayable one.
What changes in the conversion
- HEX and OKLCH describe the same sRGB color; the only difference is rounding of the last digit.
- Transparency (alpha) is kept:
#RRGGBBAA,rgb(… / 0.5),hsl(… / 50%)andoklch(… / 0.5)all carry it.
How to convert HEX to OKLCH
- Type or paste the HEX value in its line, or pick a color with the color picker.
- Read the OKLCH line, which updates as you type, and check the preview swatch.
Common colors from HEX to OKLCH
Converted with the same code as the tool:
| Color | HEX | OKLCH |
|---|---|---|
| amber (stdlib.tools accent) | #FFB224 | oklch(81.69% 0.1639 75.84) |
| teal | #0B7285 | oklch(50.9% 0.0875 215.07) |
| blue | #3B82F6 | oklch(62.31% 0.188 259.81) |
| green | #16A34A | oklch(62.71% 0.1699 149.21) |
| red | #DC2626 | oklch(57.71% 0.2152 27.33) |
| mid gray | #808080 | oklch(59.99% 0 0) |
| black | #000000 | oklch(0% 0 0) |
| white | #FFFFFF | oklch(100% 0 0) |
Frequently asked questions
Is HEX to OKLCH exact?
Yes, up to rounding: both describe the same 8-bit sRGB color, so converting back gives the same value.
Which format should I use in CSS?
HEX and rgb() work everywhere; hsl() is handy for shades written by hand; oklch() gives even lightness steps and wide-gamut colors in current browsers.
How do I write OKLCH with transparency?
Use a slash: oklch(80.9% 0.163 74.6 / 0.5); there is no separate "oklcha" function.