Every notation of the same colour
Type a value in any CSS notation and this colour converter — a "color converter" if you arrived by
the American spelling, which is the one the specification itself uses — shows you the same colour in
all six. Hex with three, four, six or eight digits; rgb(); hsl(); hwb(); oklch(); oklab();
and any of the 148 CSS colour names. The old comma syntax and the modern space syntax both parse,
because a value copied out of a stylesheet written in 2016 is still a value.
Alongside the conversions you get two things that usually need a second tool. The WCAG contrast ratio against pure black and pure white, which is the fastest way to know whether a brand colour can carry body text at all. And the nearest CSS colour name, measured perceptually rather than by subtracting one triplet of bytes from another.
What HSL gets wrong
HSL was a good idea in 1978 and its lightness axis has been misleading people ever since. Take
hsl(60 100% 50%) and hsl(240 100% 50%): both claim fifty per cent lightness, one is a yellow you
can barely read black text on, the other is a blue so dark that white text sits comfortably over it.
The number is a position between black and white in a cylinder built on top of RGB, not a
measurement of how bright the colour looks.
That is why palettes built in HSL need hand-tuning. Rotate the hue while holding saturation and lightness fixed and you do not get a family of colours of equal weight — you get yellows that glare and blues that disappear.
Why OKLCH is the one worth learning
OKLab, published by Björn Ottosson in 2020, is a colour space fitted so that Euclidean distance
inside it matches perceived difference. OKLCH is the same space in polar form, with lightness,
chroma and hue as the three numbers. Its lightness really is perceptual, so a scale from
oklch(20% 0.05 250) to oklch(90% 0.05 250) steps evenly to the eye, and holding lightness while
rotating hue gives you accent colours that all sit at the same visual weight.
It also addresses colours outside sRGB. Display P3 covers roughly a quarter more of the visible gamut than sRGB, and OKLCH can name those colours; sRGB hex cannot. This page clips anything outside sRGB to the nearest displayable colour and tells you it has done so, because the alternative — quietly handing back a different colour — is how a brand palette drifts.
The perceptual distance is also what powers the nearest-name lookup here. Comparing colours by the distance between their bytes answers a question about storage; comparing them in OKLab answers the question you actually asked, which is which name looks closest.
Alpha, and the eight-digit hex
Every notation on this page carries alpha, and each writes it differently: a fourth number after a
slash in the functional forms, two extra hex digits in the hex form. #ff000080 is red at exactly
half opacity, and #f008 is the same value written short. Alpha is not a property of the colour, it
is an instruction about compositing — which is why the contrast figures here are computed on the
opaque colour. Contrast against a translucent colour depends on what is behind it.
Converting numbers rather than colours? The number base converter handles the hex-to-decimal side of the same problem, and the case converter is the one for renaming the tokens once the palette is settled.