Skip to content
cosmodev ~/tools/oklch-converter

OKLCH Color Converter

Color & Design

Convert between hex and OKLCH — the perceptual color space behind modern CSS. Live lightness, chroma, and hue sliders with the sRGB gamut edge shown on the chroma rail; out-of-gamut points gamut-map exactly like browsers do.

Try:
#3b82f6
62.3%
0.188 / 0.204
259.8°

What it does

Converts between hex colors and OKLCH — the perceptually uniform color space CSS Color 4 brought to oklch(). Enter a hex and get its L (lightness), C (chroma), H (hue) with live sliders; drag the sliders and get back the hex, the exact CSS string, and the RGB triple. The chroma slider’s readout shows the sRGB gamut edge at your current L and H — drag past it and the color gamut-maps by chroma reduction, exactly the way browsers render out-of-gamut oklch(), with a badge saying so. Everything runs locally in your browser.

How to use it

  1. Pick a mode: From hex (a color swatch picker) or From oklch() (paste a CSS string like oklch(62.8% 0.25 29) — percent or 0-1 lightness, optional deg, optional alpha).
  2. Adjust Lightness, Chroma, and Hue with the sliders — the result updates live.
  3. Copy on the result header takes the CSS string; the smaller copy button beside the hex takes the hex.
  4. Copy share link encodes the exact L/C/H point in the URL.

Examples

Interface blue #3b82f6 parses as oklch(62.3% 0.188 259.8).

Drag Chroma to 0.35 at that hue: the readout shows 0.188 / 0.210 — you’re past the edge. The swatch shows the gamut-mapped color, and the badge flips to gamut-mapped.

In From oklch() mode, paste oklch(70% 0.15 150) — the swatch, hex, and RGB update as you type.

Good to know

  • OKLCH is the polar form of OKLab (Björn Ottosson, 2020) — the same math browsers use; hue is a degree, chroma roughly tracks saturation, lightness is perceptual.
  • Equal lightness steps look equally bright to humans — the reason design systems use OKLCH for palettes.
  • The chroma rail value is found by bisection to ±0.001; the gamut-mapped output never exceeds it.
  • Negative or >360 hue input wraps (-30 = 330), and L outside 0-1 clamps to the nearest in-range color.
Source code2 languages
cosmodev ~/src/oklch-converter

100% client-side · your data never leaves your browser. Found this useful? Share it with a teammate.