- Home
- Tools
- Color & Design
- Color Converter
- HEX to OKLCH Converter
HEX to OKLCH Converter
Convert a HEX color code to OKLCH, the lightness, chroma and hue notation that newer CSS and Tailwind CSS 4 use.
With or without the #. Three digits work too.
In OKLCH
oklch(0.6231 0.18801 259.81)
Hue
217°Alpha
100%
In the other notations
Name
dodgerbluenearest CSS name, #1e90ff
HEX to OKLCH by hand
The converter opens with #3b82f6. This is how that color gets from HEX to OKLCH, step by step.
- Read the three pairs of
#3b82f6as numbers in base 16, where the first digit counts sixteen times:3bis 3 × 16 + 11 = 59,82is 8 × 16 + 2 = 130 andf6is 15 × 16 + 6 = 246. Those are the red, green and blue values. - Divide each value by 255, so that it runs from 0 to 1: 59 ÷ 255 = 0.2314, 130 ÷ 255 = 0.5098 and 246 ÷ 255 = 0.9647.
- Take away the gamma curve of sRGB: a value above 0.04045 becomes ((value + 0.055) ÷ 1.055) ^ 2.4, a smaller one is divided by 12.92. That gives the amounts of light: R = 0.0437, G = 0.2232 and B = 0.9216. From here on the numbers are shown rounded; the calculation carries more digits.
- The first matrix of OKLab turns the light into the responses of the three kinds of cone in the eye: l = 0.4122 × R + 0.5363 × G + 0.0514 × B = 0.1852, m = 0.2119 × R + 0.6807 × G + 0.1074 × B = 0.2602 and s = 0.0883 × R + 0.2817 × G + 0.63 × B = 0.6473.
- Take the cube root of each: l′ = 0.57, m′ = 0.6384 and s′ = 0.865.
- The second matrix gives the lightness and two color axes: L = 0.2105 × l′ + 0.7936 × m′ − 0.0041 × s′ = 0.6231, a = 1.978 × l′ − 2.4286 × m′ + 0.4506 × s′ = −0.0332 and b = 0.0259 × l′ + 0.7828 × m′ − 0.8087 × s′ = −0.1851.
- Chroma is the length of (a, b) and hue its direction: C = √(a² + b²) = 0.18801 and h = atan2(b, a) = −100.19°, the same direction as 259.81°.
- Rounded:
oklch(0.6231 0.18801 259.81).
Well-known colors in HEX and OKLCH
| Color | HEX | OKLCH |
|---|---|---|
| black | #000000 | oklch(0 0 0) |
| white | #ffffff | oklch(1 0 0) |
| gray | #808080 | oklch(0.5999 0 0) |
| red | #ff0000 | oklch(0.628 0.25768 29.23) |
| orange | #ffa500 | oklch(0.7927 0.17103 70.67) |
| yellow | #ffff00 | oklch(0.968 0.21101 109.77) |
| lime | #00ff00 | oklch(0.8664 0.29483 142.5) |
| green | #008000 | oklch(0.5198 0.17686 142.5) |
| cyan | #00ffff | oklch(0.9054 0.15455 194.77) |
| blue | #0000ff | oklch(0.452 0.31321 264.05) |
| purple | #800080 | oklch(0.4209 0.19345 328.36) |
| magenta | #ff00ff | oklch(0.7017 0.32249 328.36) |
Reading an OKLCH value
- Lightness runs from 0 for black to 1 for white, and CSS also takes it as a percentage. Chroma is 0 for a gray and reaches about 0.32 for the strongest colors a HEX code can hold.
- The hue is an angle, but not the one of HSL. Pure red is at 29°, yellow at 110°, green at 142° and blue at 264°.
- A gray has a chroma of 0, and its hue is written as 0:
#808080isoklch(0.5999 0 0). - Lightness is given with four decimals and chroma with five, the fewest that lead back to the same HEX code.
The color converter shows a color in all seven notations at once, with a picker to choose it by eye.