Hex to OKLCH converter: lightness, chroma and hue from a hex code
By TechCompare · Updated · How we check
#8B5CF6 is oklch(60.56% 0.2189 292.72) in CSS, and you can paste that text into a stylesheet unchanged. It names the same color as the hex code, to within the rounding in the text.
- OKLCH
oklch(60.56% 0.2189 292.72) - RGB
rgb(139, 92, 246) - HSL
hsl(258, 90%, 66%) - CMYK
cmyk(43%, 63%, 0%, 4%)
OKLCH splits a color into three parts: lightness, chroma and hue. Lightness is how light the color looks to a person, chroma is how strong the color is, and hue is its position on the color wheel. Hex and RGB describe the same color without those parts, so the converter above works the three numbers out from the sRGB values in your hex code.
How this is calculated
The hex code gives sRGB values, and the converter turns each channel into linear light. A matrix then gives approximate cone responses, each response goes through a cube root, and a second matrix turns the result into L, a and b. Chroma is the length of the (a, b) pair and hue is its angle, so OKLCH is the same space in polar form. Björn Ottosson designed Oklab to be simple to use while still predicting perceived lightness, chroma and hue well. You don't need the matrix numbers, since the converter does that work.
Lightness is where OKLCH and HSL disagree. HSL gives pure yellow 50% lightness and pure blue 50%, but OKLCH gives 96.8% and 45.2%. Yellow is the lighter of the two in OKLCH. MDN calls the L in oklch() the perceived lightness, which is different from the L in hsl(), where it represents lightness as compared to other colors.
A gray has chroma 0, and the converter writes its hue as 0 too, since a gray has no real hue. Mid gray is oklch(59.99% 0 0) and white is oklch(100% 0 0). In CSS, chroma can be a number or a percent, and 100% equals 0.4. MDN says chroma has no fixed top, but in practice it doesn't exceed 0.5. The converter rounds lightness and hue to two decimals and chroma to four. That's just enough for the oklch() text to give back every hex code within one step per channel, but the hex code stays the exact source.
Verdict
To make a lighter or darker variant, change the lightness and keep chroma and hue the same, then check the result in a browser. This converter reads hex, RGB, HSL and CMYK but not OKLCH. To get a hex code back from an OKLCH value, type it into the OKLCH fields of the Color Picker. A variant can also land outside sRGB, so read OKLCH in CSS before you ship a wide-gamut palette.
More Color scenarios
Related guides
Frequently asked questions
Is oklch() supported in browsers?
What are the OKLCH ranges?
Why is chroma 0 for gray, and what hue does gray have?
Is OKLCH the same as LCH?
Related tools
Contrast Checker
Check color contrast ratios for WCAG AA/AAA accessibility compliance.
Use toolJSON Formatter
Validate, format, and minify JSON. Browse it as a tree, run JSONPath queries, compare two documents, or validate against a JSON Schema.
Use toolAspect Ratio Visualizer
Visually compare width differences between 16:9, 21:9, and 32:9 monitors.
Use tool