DESIGN & WEB

Colour Converter

Convert a colour between hex, rgb(), hsl(), hwb(), oklch(), oklab() and naive CMYK in CSS Color 4 syntax, with WCAG contrast and the better text colour.

The same colour in every notation a stylesheet, a design tool or a print brief asks for — ready to paste — with the perceptual OKLCH values that modern CSS uses.

Example: #1f7a8c is rgb(31 122 140), hsl(189.9 63.7% 33.5%), hwb(189.9 12.2% 45.1%) and oklch(0.5363 0.0854 214.32); it takes white text (contrast 5.0 : 1).

v0.1.0 · last reviewed 19 September 2026
Loading the workspace…
BUILT TO BE UNDERSTOOD

One colour,
seven ways to write it.

What each notation encodes, why OKLCH is different, and what CMYK here does not promise.

Hex, RGB, HSL, HWB

All four describe the same sRGB colour. Hex and rgb() give the three channels directly; hsl() re-expresses them as a hue angle, saturation and lightness, and hwb() as a hue plus how much white and black are mixed in — the notation painters find most natural. The conversions follow CSS Color Module Level 4 exactly, so the strings paste into a stylesheet as they are. Inputs accept any of these forms.

OKLCH and OKLab

HSL lightness is a numeric trick: a saturated yellow and a saturated blue at the same HSL lightness look nothing alike in brightness. OKLab is a perceptual space in which equal numeric steps look like equal visual steps, and OKLCH is its polar form — lightness, chroma and hue. Modern CSS supports both, and they are the right space for generating tints, palettes and gradients that look even. The page computes them with the CSS Color 4 matrices from linear sRGB and checks the result against the specification's own example (sRGB red = oklch(0.628 0.2577 29.23)).

Contrast, and the CMYK caveat

The contrast figures are WCAG 2 ratios of the colour against white and against black, and the suggested text colour is simply whichever is higher; the Colour Palette page checks pairs against the 4.5 : 1 and 3 : 1 thresholds. CMYK is given by the naive formula (k = 1 − max, the rest scaled) with no ICC profile; real press output depends on the printer's profile and paper, so treat it as an approximation for briefs, not for prepress. Nothing leaves the browser; the same four anonymous usage counts as the rest of the site apply.

SOURCES

Last reviewed 19 September 2026. How results are checked: How we verify.