OKLCH converter — HEX, RGB and any CSS colour to oklch() and back

Enter any CSS colour to get its oklch() and oklab() values, or set lightness, chroma and hue directly to get a HEX and RGB colour, with a gamut check and ready-to-paste CSS.

Live demo · real result from this tool
Input
OKLCHoklch(62.31% 0.188 259.81)
OKLab
oklab(62.31% -0.0332 -0.1851)
HEX
#3b82f6
RGB
rgb(59, 130, 246)
In sRGB gamut
Yes
L / C / H
62.31% / 0.188 / 259.81°

Colours

CSS

color: #3b82f6;color: oklch(62.31% 0.188 259.81);

Processed on your device — nothing is uploaded.

How to use the OKLCH converter

  1. Choose the Input: Any colour or OKLCH numbers.
  2. For Any colour, enter a value in the Colour field, for example #3b82f6, rgb(59 130 246) or a CSS name.
  3. For OKLCH numbers, drag Lightness L (0–100%), Chroma C (0–0.4) and Hue H (0–360°).
  4. Read the OKLCH, OKLab, HEX and RGB values, and check In sRGB gamut.
  5. Copy the two-line CSS: a HEX fallback followed by the oklch() value.

What it does and when to use it

OKLCH has become a popular way to write colours in CSS and in design tokens. Tailwind v4 defines its whole palette in it. Raise L and the colour gets lighter without changing hue; lower C and it turns greyer. This converter moves your existing HEX and RGB colours into OKLCH, and turns OKLCH numbers back into values any tool understands.

Use it when migrating a palette to OKLCH, when you want to see whether a vivid OKLCH colour fits on a normal screen, or to learn the scale by dragging the sliders. To change lightness by a set amount in OKLCH, use lighten / darken. For every other notation of a colour at once, try the colour converter, and see real OKLCH palettes in the Tailwind colour palette.

How it works

The conversion follows CSS Color Module Level 4 and Björn Ottosson’s published matrices. sRGB values are first linearised, then multiplied by a matrix, cube-rooted and multiplied by a second matrix to give OKLab L, a and b. OKLCH is the polar form: C = √(a² + b²) and H = atan2(b, a) in degrees.

Going back reverses those steps. If any RGB channel falls outside 0–1, the colour is out of gamut. The tool then searches for the highest chroma at the same L and H whose clipped version is within a just-noticeable difference (ΔE OK 0.02) of it. That is the CSS Color 4 gamut-mapping method.

Worked examples

These come from the converter.

Tailwind v3 blue-500, #3b82f6. OKLCH oklch(62.31% 0.188 259.81), OKLab oklab(62.31% -0.0332 -0.1851). It is inside the sRGB gamut.

A green too vivid for sRGB. L 70%, C 0.4, H 150 gives In sRGB gamut: No. The mapped HEX is #00c248; simply clipping the channels would give #00d600, a lighter, yellower green.

Pure red in OKLCH. oklch(62.8% 0.2577 29.23) converts to #ff0000, rgb(255, 0, 0).

Limits and tips

  • The highest chroma a screen can show depends on hue and lightness: vivid yellows exist only at high lightness, vivid blues only at low lightness.
  • Hue has no meaning when chroma is 0; greys show H as 0.
  • Conversion runs in your browser.

Frequently asked questions

What do L, C and H mean in OKLCH?
L is perceived lightness from 0% (black) to 100% (white). C is chroma, how colourful it is, from 0 for grey up to 0.3132 for pure sRGB blue
Why use OKLCH instead of HSL?
In OKLCH, equal lightness numbers look equally light across hues. In HSL, yellow and blue at 50% lightness look very different. That makes OKLCH better for building palettes, adjusting lightness for contrast and creating themes.
What does "In sRGB gamut No" mean?
The colour is more vivid than a standard sRGB screen can show. The HEX value is then the nearest displayable colour found by lowering chroma, while the oklch() line keeps the original for wide-gamut screens.
Why is the mapped colour different from the plain clip?
Clipping cuts each RGB channel to 0–255, which can shift the hue and lightness. Gamut mapping keeps the lightness and hue and reduces chroma instead, which usually looks closer to what you meant.
Do browsers support oklch()?
Current versions of the major browsers support it. Keep the HEX line before it, as the tool's CSS output does, so older browsers still get a colour.

Sources

  1. CSS Color Module Level 4 — OKLab and OKLCH, sample conversion code and gamut mapping — W3C, accessed 2026-10-08
  2. Björn Ottosson, A perceptual color space for image processing (OKLab) — bottosson.github.io, accessed 2026-10-08

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close