- Home
- Tools
- Color & Design
- Color Converter
- OKLCH to HEX Converter
OKLCH to HEX Converter
Turn an oklch() color into a six-digit HEX code for programs that do not read OKLCH. A color outside sRGB is brought into range.
The numbers alone will do: 0.7 0.15 150.
In HEX
#4cb86a
Hue
137°Alpha
100%
In the other notations
Name
mediumseagreennearest CSS name, #3cb371
OKLCH to HEX by hand
The converter opens with oklch(0.7 0.15 150). This is how that color gets from OKLCH to HEX, step by step.
- Turn chroma and hue back into the two color axes: a = C × cos(h) = 0.15 × cos(150°) = −0.1299 and b = C × sin(h) = 0.15 × sin(150°) = 0.075. From here on the numbers are shown rounded; the calculation carries more digits.
- Undo the second matrix of OKLab: l′ = L + 0.3963 × a + 0.2158 × b = 0.6647, m′ = L − 0.1056 × a − 0.0639 × b = 0.7089 and s′ = L − 0.0895 × a − 1.2915 × b = 0.6148.
- Cube each of them to get the responses of the three kinds of cone in the eye: l = 0.2937, m = 0.3563 and s = 0.2323.
- Undo the first matrix to get the amounts of red, green and blue light: R = 4.0767 × l − 3.3077 × m + 0.231 × s = 0.0724, G = −1.2684 × l + 2.6098 × m − 0.3413 × s = 0.478 and B = −0.0042 × l − 0.7034 × m + 1.7076 × s = 0.1449.
- Put the gamma curve of sRGB back: a value above 0.0031308 becomes 1.055 × value ^ (1 ÷ 2.4) − 0.055, a smaller one is multiplied by 12.92. That gives 0.2984, 0.7207 and 0.4167 for red, green and blue.
- Multiply by 255 and round: 76, 184 and 106.
- Write each of the three as two digits in base 16, the first one counting sixteen times: 76 = 4 × 16 + 12 is
4c, 184 = 11 × 16 + 8 isb8and 106 = 6 × 16 + 10 is6a. Together:#4cb86a.
Well-known colors in OKLCH and HEX
| Color | OKLCH | HEX |
|---|---|---|
| black | oklch(0 0 0) | #000000 |
| white | oklch(1 0 0) | #ffffff |
| gray | oklch(0.5999 0 0) | #808080 |
| red | oklch(0.628 0.25768 29.23) | #ff0000 |
| orange | oklch(0.7927 0.17103 70.67) | #ffa500 |
| lime | oklch(0.8664 0.29483 142.5) | #00ff00 |
| green | oklch(0.5198 0.17686 142.5) | #008000 |
| cyan | oklch(0.9054 0.15455 194.77) | #00ffff |
| purple | oklch(0.4209 0.19345 328.36) | #800080 |
| magenta | oklch(0.7017 0.32249 328.36) | #ff00ff |
| teal | oklch(0.5431 0.09271 194.77) | #008080 |
| maroon | oklch(0.3767 0.15458 29.23) | #800000 |
When the color does not fit in a HEX code
- OKLCH can describe colors that sRGB cannot show, and a HEX code is sRGB. If one of the three amounts of light comes out below 0 or above 1, the color is out of range.
- This converter then lowers the chroma until the color fits and keeps lightness and hue:
oklch(0.7 0.3 150)becomes#00be58. Chrome currently cuts off the channels instead and shows#00cb00. - Lightness may be a number from 0 to 1 or a percentage, chroma a number or a percentage of 0.4, and the hue an angle with or without
deg. - A HEX code has 256 levels per channel, so the trip back is not exact:
#4cb86aisoklch(0.7005 0.15061 149.91).
The color converter shows a color in all seven notations at once, with a picker to choose it by eye.