Color Converter: HEX, RGB, HSL and OKLCH

Convert colors between HEX, RGB, HSL and OKLCH, one or many at a time, in CSS syntax.

How to use

What it checks and how it works

The tool parses each color with culori and writes HEX, RGB, HSL and OKLCH in the space-separated syntax of CSS Color Module Level 4, with a slash and the alpha value when a color is translucent. OKLCH is the polar form of Oklab, the perceptual color space described by Björn Ottosson, who designed it to predict perceived lightness, chroma and hue better than older spaces such as HSL. A color written in OKLCH can fall outside the sRGB gamut that HEX, RGB and HSL describe. Such a color is brought inside by lowering its chroma while keeping its lightness and hue, using culori's clampChroma, and the table marks it as mapped. That is culori's method and not the exact algorithm in CSS Color 4. Values are rounded, so converting back and forth can change the last digit.

Why does an OKLCH color change when I convert it to HEX?

HEX covers sRGB only. If the OKLCH color lies outside sRGB, its chroma is lowered to fit and the tool marks it as mapped.

Which syntax does the tool write?

The space-separated form from CSS Color Module Level 4, for example rgb(11 95 255), with a slash and the alpha value when the color is translucent.

Can I convert many colors at once?

Yes. Put one color on each line and the table lists every format for each, which you can copy as plain values or as CSS custom properties.

Sources

Related tools

Privacy

Runs in your browser; nothing is uploaded. The interactive tool needs JavaScript.