OKLCH is the color format CSS has been waiting for. It describes a color the way people see it, so changing the lightness actually changes how light the color looks, and two colors with the same lightness really do look equally light. That makes it far easier to build shades, hover states, dark themes and accessible color pairs than with HEX or HSL.
This guide explains what the three OKLCH numbers mean, how to convert HEX to OKLCH (and back), why it beats HSL for design systems, and how to use it safely in production CSS, including fallbacks for older browsers.
What the three numbers mean
An OKLCH color in CSS looks like oklch(62.3% 0.188 259.8). The three values are:
| Value | Name | Range | What it controls |
|---|---|---|---|
62.3% | L, lightness | 0% (black) to 100% (white) | How light the color looks to the eye |
0.188 | C, chroma | 0 (gray) upward, rarely above 0.37 | How vivid or saturated it is |
259.8 | H, hue | 0 to 360 degrees | Which color it is: red, green, blue and so on |
You can add transparency with a slash, as in other modern CSS color functions: oklch(62.3% 0.188 259.8 / 50%).
The "OK" refers to OKLab, the color space underneath, published by Björn Ottosson in 2020. "LCH" means lightness, chroma and hue. The important part is that OKLab was designed so equal number changes look like equal visual changes.
HEX to OKLCH: common examples
Here are some familiar colors converted exactly. Notice how the lightness values reflect what you actually see:
| HEX | Color | OKLCH |
|---|---|---|
#ffffff | White | oklch(100% 0 0) |
#808080 | Mid gray | oklch(60% 0 0) |
#000000 | Black | oklch(0% 0 0) |
#ff0000 | Pure red | oklch(62.8% 0.258 29.2) |
#ffff00 | Pure yellow | oklch(96.8% 0.211 109.8) |
#0000ff | Pure blue | oklch(45.2% 0.313 264.1) |
#22c55e | Green | oklch(72.3% 0.192 149.6) |
#3b82f6 | Bright blue | oklch(62.3% 0.188 259.8) |
Grays have zero chroma, so their hue doesn't matter. CSS lets you write it as none or any number.
The conversion itself is a few steps of math (HEX to linear RGB, then to OKLab, then to polar coordinates), so it's easiest to let a tool do it. Our converter shows HEX, RGB, HSL and OKLCH side by side and converts in both directions.
Why OKLCH beats HSL
HSL looks similar on paper (hue, saturation, lightness), but its lightness is a mathematical value, not a visual one. Pure yellow and pure blue are both hsl(… 100% 50%), so HSL says they are equally light. In OKLCH, yellow is 96.8% and blue is 45.2%, which matches what your eyes report: yellow is nearly white, blue is dark.
That difference causes real problems in HSL:
- Inconsistent shades. A "500" shade built at the same HSL lightness across hues gives a pale yellow and a deep blue, so every hue in a palette needs hand-tuning.
- Unpredictable contrast. Swapping a button's hue in HSL can quietly break its text contrast, because the perceived lightness changed even though the L value didn't.
- Muddy gradients and hovers. Darkening by lowering HSL lightness often shifts the hue or turns colors gray.
In OKLCH, you can keep L fixed and rotate H to get a set of colors that look equally light, which is exactly what you want for status colors, chart series and themed buttons.
Build shades and hover states
Because lightness is visual, a consistent shade scale is just a series of lightness steps with the same hue:
:root {
--brand-300: oklch(80% 0.10 260);
--brand-500: oklch(62% 0.19 260);
--brand-700: oklch(45% 0.17 260);
}
A few practical rules:
- Lower chroma at the extremes. Very light and very dark colors can't hold much saturation, so reduce C toward the ends of the scale to avoid colors the screen can't show.
- Hover states: drop lightness by about 5 to 8 percentage points and keep hue and chroma the same.
- Same lightness, different hue: for success, warning and error colors that feel equally weighted, give them the same L and C and change only H.
Newer CSS can even calculate a hover color from a base color with relative color syntax: oklch(from var(--brand-500) calc(l - 0.07) c h). It works in current versions of the major browsers, but older devices ignore it, so give those a fallback.
Gamut: colors your screen can't show
OKLCH can describe colors that are more vivid than an ordinary sRGB screen can display. Wide-gamut screens (Display P3, found on most recent phones and Macs) can show some of them; older screens can't. When a color is out of range, the browser maps it to the closest color it can show.
That's useful, because you can use richer colors on screens that support them. It also means the color you pick may look slightly different on another device. To stay predictable:
- Keep chroma moderate (roughly 0.25 or lower for most hues) when you need a color to look the same everywhere.
- Use a converter that warns you when a value is outside sRGB.
- Check your final colors on more than one screen if brand accuracy matters.
Using OKLCH in production CSS
The basic oklch() function works in all major browsers released since 2023 (Chrome and Edge 111, Safari 15.4, Firefox 113). For older browsers, the simplest fallback is to declare the HEX value first. Browsers that don't understand the second line keep the first:
.button {
background: #3b82f6;
background: oklch(62.3% 0.188 259.8);
}
For larger systems, wrap the OKLCH variables in a support check:
:root { --brand: #3b82f6; }
@supports (color: oklch(0% 0 0)) {
:root { --brand: oklch(62.3% 0.188 259.8); }
}
Two more places OKLCH shines:
- Gradients:
linear-gradient(in oklch, #3b82f6, #22c55e)blends through vivid in-between colors instead of the gray middle you often get in sRGB. - Mixing:
color-mix(in oklch, var(--brand) 70%, white)makes tints that stay true to the original hue.
Tailwind CSS version 4 defines its default color palette in OKLCH, so if you use Tailwind, you are likely using it already.
OKLCH and accessible contrast
OKLCH lightness is a good guide to contrast, but not a replacement for checking it. WCAG contrast ratios use a different formula, and the gap you need depends on the hue. Two real examples with white text:
- On
#3b82f6(lightness 62.3%), white text reaches only 3.68:1, which fails the 4.5:1 minimum for normal text. - On
#2563eb(lightness 54.6%), white text reaches 5.17:1 and passes.
So darkening a button by about 8 points of OKLCH lightness can be the difference between failing and passing. Pick your colors in OKLCH, then convert them to HEX and confirm every text and background pair with a contrast checker before you ship.
Frequently asked questions
What is OKLCH in CSS?
OKLCH is a CSS color format with three values: lightness (0% to 100%), chroma (how vivid the color is) and hue (0 to 360 degrees). It is built on the OKLab color space, so equal changes in the numbers look like equal changes to the eye, which makes shades and themes far easier to build than with HEX or HSL.
How do I convert HEX to OKLCH?
Use a converter: the math goes from HEX to linear RGB, then to OKLab, then to lightness, chroma and hue. For example, #3b82f6 is oklch(62.3% 0.188 259.8) and pure red #ff0000 is oklch(62.8% 0.258 29.2). Our free color converter does it in both directions.
Is OKLCH supported in all browsers?
The oklch() function works in all major browsers released since 2023, including Chrome and Edge 111, Safari 15.4 and Firefox 113. Newer extras such as relative color syntax need more recent versions, so add a HEX fallback line before the OKLCH value for older devices.
Why use OKLCH instead of HSL?
HSL lightness is not what the eye sees: pure yellow and pure blue both have 50% HSL lightness, but in OKLCH yellow is 96.8% and blue is 45.2%. OKLCH lightness matches perception, so shades, hover states and color sets with equal visual weight come out consistent without hand-tuning.
What does out of gamut mean for an OKLCH color?
It means the color is more vivid than the screen can display. OKLCH can describe colors beyond the standard sRGB range; wide-gamut screens show some of them and the browser maps the rest to the closest color it can show. Keep chroma moderate when a color must look identical everywhere.