HSL to hex
Rounding to 8 bits per channel means several nearby HSL values can share one hex code.
Paste a HSL value. Other formats work too.
#00abe7Need every format at once? Open in the full picker
Worked examples
Common colors converted from HSL to hex, computed with the same engine the picker uses.
| Color | HSL | hex | Copy |
|---|---|---|---|
| Pure red | hsl(0 100% 50%) | #ff0000 | |
| Pure green | hsl(120 100% 50%) | #00ff00 | |
| Pure blue | hsl(240 100% 50%) | #0000ff | |
| White | hsl(300 100% 100%) | #ffffff | |
| Mid gray | hsl(300 0% 50.2%) | #808080 | |
| Black | hsl(0 0% 0%) | #000000 | |
| Interface blue | hsl(216.9 89.9% 61%) | #4287f5 | |
| Success green | hsl(142.1 70.6% 45.3%) | #22c55e | |
| Danger red | hsl(0 84.2% 60.2%) | #ef4444 | |
| Warning amber | hsl(37.7 92.1% 50.2%) | #f59e0b | |
| Editor black | hsl(0 0% 11.8%) | #1e1e1e | |
| Warm sand | hsl(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 color that cannot be represented in the target format is handled deliberately rather than by accident.
When the source describes a color 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 colors.