What are OKLCH and HEX?
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. HEX writes the red, green and blue channels of sRGB as two hexadecimal digits each, from 00 to FF.
Needed when an OKLCH color from modern CSS must go to a tool, an e-mail template or an older browser that only knows HEX; colors outside sRGB are clipped to the nearest one.
The color converter below starts from OKLCH and highlights HEX, next to HWB, LAB, LCH and CSS names.
OKLCH vs HEX
| OKLCH | HEX | |
|---|---|---|
| Notation | oklch(80.9% 0.163 74.6) | #RRGGBB, #RGB, #RRGGBBAA |
| In CSS | Chrome 111+, Safari 15.4+, Firefox 113+ | all browsers |
| Typical use | design systems, accessible palettes, wide-gamut screens | CSS, design handoff, brand guides |
Formula
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. Then: Write each channel (0–255) as two hexadecimal digits and join them: 255 → FF, 178 → B2 (178 = 11 × 16 + 2), 36 → 24, so rgb(255, 178, 36) is #FFB224. Values below 16 need a leading zero (10 → 0A).
What changes in the conversion
- The conversion is not perfectly reversible: OKLCH can describe colors that sRGB cannot show; they are clipped to the nearest HEX.
- Transparency (alpha) is kept:
#RRGGBBAA,rgb(… / 0.5),hsl(… / 50%)andoklch(… / 0.5)all carry it.
How to convert OKLCH to HEX
- Type or paste the OKLCH value in its line, or pick a color with the color picker.
- Read the HEX line, which updates as you type, and check the preview swatch.
Common colors from OKLCH to HEX
Converted with the same code as the tool:
| Color | OKLCH | HEX |
|---|---|---|
| amber (stdlib.tools accent) | oklch(81.69% 0.1639 75.84) | #FFB224 |
| teal | oklch(50.9% 0.0875 215.07) | #0B7285 |
| blue | oklch(62.31% 0.188 259.81) | #3B82F6 |
| green | oklch(62.71% 0.1699 149.21) | #16A34A |
| red | oklch(57.71% 0.2152 27.33) | #DC2626 |
| mid gray | oklch(59.99% 0 0) | #808080 |
| black | oklch(0% 0 0) | #000000 |
| white | oklch(100% 0 0) | #FFFFFF |
Frequently asked questions
Is OKLCH to HEX exact?
Close, not exact: rounding and gamut limits apply, as explained above. For brand colors, keep the official value of each format instead of converting back and forth.
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 HEX with transparency?
Add two more digits for alpha: #FFB22480 is the amber at 50% opacity (80 hex = 128 of 255).