HSL to hex

Rounding to 8 bits per channel means several nearby HSL values can share one hex code.

Hue
Alpha
100%
hex
#4287f5

Paste a HSL value — other formats work too.

Need every format at once? Open in the full picker

Worked examples

Common colours converted from HSL to hex, computed with the same engine the picker uses.

ColourHSLhexCopy
Pure redhsl(0 100% 50%)#ff0000
Pure greenhsl(120 100% 50%)#00ff00
Pure bluehsl(240 100% 50%)#0000ff
Whitehsl(300 100% 100%)#ffffff
Mid greyhsl(300 0% 50.2%)#808080
Blackhsl(0 0% 0%)#000000
Interface bluehsl(216.9 89.9% 61%)#4287f5
Success greenhsl(142.1 70.6% 45.3%)#22c55e
Danger redhsl(0 84.2% 60.2%)#ef4444
Warning amberhsl(37.7 92.1% 50.2%)#f59e0b
Editor blackhsl(0 0% 11.8%)#1e1e1e
Warm sandhsl(42.5 74.3% 66.5%)#e9c46a

How the conversion works

Rounding to 8 bits per channel means several nearby HSL values can share one hex code.

Both formats are computed from a single canonical representation — CIE XYZ with a D65 white point, held in floating point — rather than by chaining one format into the next. That matters because chained conversions accumulate rounding error, and because it means a colour that cannot be represented in the target format is handled deliberately rather than by accident.

When the source describes a colour outside the target's gamut, chroma is reduced in OKLCh while lightness and hue are held, following the CSS Color 4 gamut mapping algorithm. Clipping each channel independently would be simpler but visibly shifts hue on saturated colours.

Related conversions