Find Color Codes

HSL to Hex Converter

Enter an HSL triple and get the hex code. This is the direction you need when you have adjusted a color in HSL and now have to write it into a stylesheet or hand it to someone who expects hex.

How the conversion works

If saturation is zero the result is a grey and every channel equals the lightness. Otherwise, compute two intermediate values from lightness and saturation, then derive each channel by offsetting the hue by ±⅓ of the wheel and mapping it through a piecewise function.

The offsets are what place red, green and blue 120° apart, which is the whole geometric basis of the model.