Skip to the content

HSL to HEX Converter

Enter a hue, a saturation and a lightness and get the six-digit HEX code of that color.

The numbers alone will do: 200, 60, 50.

In HEX

#3399cc

Hue
200°Alpha
100%

In the other notations

Name

steelbluenearest CSS name, #4682b4

Share this tool:TwitterFacebookLinkedInWhatsAppEmail

HSL to HEX by hand

The converter opens with hsl(200, 60%, 50%). This is how that color gets from HSL to HEX, step by step.

  1. Write the two percentages as fractions: S = 0.6 and L = 0.5.
  2. Chroma is how far the strongest channel will be from the weakest: C = (1 − |2 × L − 1|) × S = (1 − |2 × 0.5 − 1|) × 0.6 = 0.6.
  3. Divide the hue by 60° to see which sixth of the color wheel it is in: 200 ÷ 60 = 3.3333. A number from 3 to 4 lies between cyan and blue.
  4. There blue is the strongest channel and gets C, red is the weakest and gets 0, and green lies in between with X = C × (1 − |3.3333 mod 2 − 1|) = 0.6 × 0.6667 = 0.4.
  5. Add m = L − C ÷ 2 = 0.5 − 0.3 = 0.2 to all three, so that the lightness comes out right: red 0.2, green 0.6 and blue 0.8.
  6. Multiply by 255 and round: 51, 153 and 204.
  7. Write each of the three as two digits in base 16, the first one counting sixteen times: 51 = 3 × 16 + 3 is 33, 153 = 9 × 16 + 9 is 99 and 204 = 12 × 16 + 12 is cc. Together: #3399cc.

Well-known colors in HSL and HEX

ColorHSLHEX
blackhsl(0, 0%, 0%)#000000
whitehsl(0, 0%, 100%)#ffffff
grayhsl(0, 0%, 50.2%)#808080
redhsl(0, 100%, 50%)#ff0000
orangehsl(38.8, 100%, 50%)#ffa500
yellowhsl(60, 100%, 50%)#ffff00
limehsl(120, 100%, 50%)#00ff00
greenhsl(120, 100%, 25.1%)#008000
cyanhsl(180, 100%, 50%)#00ffff
bluehsl(240, 100%, 50%)#0000ff
purplehsl(300, 100%, 25.1%)#800080
magentahsl(300, 100%, 50%)#ff00ff

What the three numbers do

  • The hue is an angle on the color wheel, so it wraps around: 360° is the same as 0°, and −30° the same as 330°.
  • Lightness overrules the other two at its ends. At 0% the result is #000000 and at 100% it is #ffffff, whatever the hue and the saturation say.
  • A color is at its purest at a lightness of 50%. Above that it is mixed with white, below it with black.
  • CSS takes the hue with or without deg, and the three numbers with commas or with spaces only: hsl(200 60% 50%) is the same color.

The color converter shows a color in all seven notations at once, with a picker to choose it by eye.

See all 8