OKLCH to Hex Converter
Convert an OKLCH color value back into a 6-digit hex code, with exact round-trip accuracy for CSS oklch() colors and design tokens.

Built by
Swapnil SanghviFull-Stack Web Developer & WordPress Developer
Swapnil Sanghvi is a full-stack web and WordPress developer, UI designer, and full-time freelancer who builds and maintains Hex Calculator.
Further reading: CSS Colors — W3Schools
How OKLCH to Hex Conversion Works
OKLCH's chroma and hue are polar coordinates around Oklab's a and b axes, so the first step converts them back to Cartesian form. From there, the reverse of the Oklab transform produces linear-light RGB, which gets gamma-encoded into standard sRGB and rounded to the 0-255 integers a hex code represents.
OKLCH to Hex Example, Step by Step
oklch(54.6% 0.2152 262.9) = #2563EB
oklch(54.6% 0.2152 262.9) = #2563EB
a = C x cos(H) = 0.2152 x cos(262.9°) = -0.0267 b = C x sin(H) = 0.2152 x sin(262.9°) = -0.2135 Oklab(0.546, -0.0267, -0.2135) -> linear RGB -> sRGB Round to bytes: R=37, G=99, B=235 -> #2563EB
| Step | Description | Result |
|---|---|---|
| Convert polar to Cartesian | a = C·cos(H), b = C·sin(H) | a=-0.0267, b=-0.2135 |
| Convert Oklab to linear RGB | apply the inverse Oklab matrix | linear R, G, B |
| Apply sRGB gamma encoding | convert linear values to standard sRGB | R=37, G=99, B=235 |
| Convert to hex | round and pair each channel | #2563EB |
This exactly reverses the hex-to-OKLCH example — the two tools are precise inverses of each other for in-gamut colors.
Where OKLCH to Hex Actually Comes Up
Providing a CSS oklch() Fallback
Not every browser or tool supports the oklch() function yet — converting to hex gives you a safe fallback value to declare alongside the modern syntax.
oklch(54.6% 0.2152 262.9) -> #2563EB fallback
Exporting a Modern Design System's Color Scale
Component libraries like shadcn/ui and Radix increasingly define color scales in OKLCH for perceptual consistency — converting to hex supports tools or platforms still expecting traditional colors.
OKLCH design tokens -> hex exports
Debugging a Computed OKLCH Value
When a CSS variable or computed style outputs an OKLCH value, converting it to hex gives you a quick way to identify or compare the actual color visually.
computed oklch() -> recognizable hex
Common Mistakes With OKLCH to Hex
- Entering chroma as a percentage — chroma in OKLCH is an unbounded decimal (typically 0-0.4), not a 0-100% value like lightness.
- Expecting every OKLCH value to map to a valid hex — very high-chroma values can fall outside what sRGB screens can display and get clamped.
- Forgetting hue wraps at 360° — a value like 400° is equivalent to 40°.
Why Use This Calculator Instead of Doing the Math Yourself
- Handles the polar-to-Cartesian conversion and matrix transform for you
- Runs entirely in your browser — nothing you type gets sent anywhere
- Clamps out-of-gamut colors to valid RGB instead of producing garbage
- Normalizes hue angles outside 0-360 automatically
Limitations
- Converts back to sRGB — out-of-gamut OKLCH values get clamped to the nearest displayable sRGB color rather than rejected.
Frequently Asked Questions
How do you convert OKLCH to hex?
Convert the polar chroma and hue back into Oklab's Cartesian a and b coordinates, then run the Oklab-to-linear-RGB matrix transform in reverse, and finally re-apply sRGB gamma encoding to get 0-255 channel values.
What format does this tool accept for OKLCH input?
Either plain space-separated values (54.6% 0.2152 262.9) or a full oklch() function string (oklch(54.6% 0.2152 262.9)) — both work the same.
Does OKLCH to hex round-trip exactly?
Yes — oklch(54.6% 0.2152 262.9) converts back to exactly #2563EB, with no drift, as long as the OKLCH value itself came from a hex-to-OKLCH conversion without manual rounding.
What happens if I enter an OKLCH color outside the sRGB gamut?
High-chroma OKLCH values can represent colors sRGB screens can't display. This tool clamps the result to the nearest valid 0-255 RGB value rather than producing an invalid hex code.
Can I use negative or over-360 hue values?
Hue is treated as a circular value 0-360; this tool normalizes hue angles outside that range automatically.
How do I get a hex fallback for a CSS oklch() color?
Convert your oklch() value here to get the equivalent hex code — useful as a fallback declaration for browsers or tools that don't yet support the oklch() CSS function.
My design system defines colors in OKLCH — how do I export them as hex?
Convert each color in your OKLCH-based scale (common in modern systems like shadcn/ui and Radix) here to produce the corresponding hex values for tools or platforms that expect traditional hex.