HSL to HEX Converter

HSL in, HEX color code out — with the working shown.

To convert HSL to HEX, normalise the input, convert HSL back to RGB, write out the HEX value, then check the gamut. For example, hsl(215.4 92.6% 57.6%) in HSL is #2f81f7 in HEX.

This is a free HSL to HEX converter. Type or paste any hue, saturation and lightness into the field above and the HEX value updates as you type, along with every other notation the web understands. HEX is a six-digit hexadecimal number, two digits per channel, written with a leading #.

Conversions run entirely in your browser using the same color engine as the rest of the site: values round-trip through linear sRGB and CIE XYZ rather than through an approximation, so what you copy is accurate to the last digit the format can carry.

How to convert HSL to HEX

  1. Normalise the input. Read the HSL value and scale each component into the 0–1 range the maths expects.
  2. Convert HSL back to RGB. HSL is not the display's native model, so the first move is always back to red, green and blue.
  3. Write out the HEX value. Convert back through sRGB and format the result as HEX.
  4. Check the gamut. Clamp anything that falls outside what an sRGB display can show, so the value you copy is the value you get.

Worked example: hsl(215.4 92.6% 57.6%) converts to #2f81f7. That color is Dodger Blue, and the tool above shows each intermediate step for whatever value you enter.

Common HSL to HEX values

The twenty colors people look up most often, converted from HSL to HEX. Every row is computed by the same engine as the tool above.

ColorHSLHEX
Whitehsl(0 0% 100%)#ffffff
Blackhsl(0 0% 0%)#000000
Redhsl(0 100% 50%)#ff0000
Limehsl(120 100% 50%)#00ff00
Bluehsl(240 100% 50%)#0000ff
Yellowhsl(60 100% 50%)#ffff00
Cyanhsl(180 100% 50%)#00ffff
Magentahsl(300 100% 50%)#ff00ff
Silverhsl(0 0% 75.3%)#c0c0c0
Grayhsl(0 0% 50.2%)#808080
Maroonhsl(0 100% 25.1%)#800000
Olivehsl(60 100% 25.1%)#808000
Greenhsl(120 100% 25.1%)#008000
Purplehsl(300 100% 25.1%)#800080
Tealhsl(180 100% 25.1%)#008080
Navyhsl(240 100% 25.1%)#000080
Orangehsl(38.8 100% 50%)#ffa500
Pinkhsl(349.5 100% 87.6%)#ffc0cb
Goldhsl(50.6 100% 50%)#ffd700
Crimsonhsl(348 83.3% 47.1%)#dc143c

HSL and HEX, briefly

HSL is a cylindrical remapping of RGB into hue (0–360°), saturation (0–100%) and lightness (0–100%). Valid range: H 0–360°, S and L 0–100%.

HEX is a six-digit hexadecimal number, two digits per channel, written with a leading #. Valid range: #000000 to #ffffff.

Frequently asked questions

How do you convert HSL to HEX?

1. Read the HSL value and scale each component into the 0–1 range the maths expects. 2. HSL is not the display's native model, so the first move is always back to red, green and blue. 3. Convert back through sRGB and format the result as HEX. 4. Clamp anything that falls outside what an sRGB display can show, so the value you copy is the value you get. The converter on this page does all of it as you type, and shows the working underneath.

What is hsl(0 100% 50%) in HEX?

Pure red, hsl(0 100% 50%), is #ff0000 in HEX. There is a table of twenty common colors converted to HEX further up this page.

What is hsl(215.4 92.6% 57.6%) in HEX?

hsl(215.4 92.6% 57.6%) converts to #2f81f7. It is a dodger blue, and you can paste any other value into the field at the top of the page to convert it.

Is HSL to HEX conversion lossless?

Within sRGB, yes — converting to HEX and back returns the value you started with. The only rounding happens when a component is written out to a fixed number of decimal places.

Can I use HEX directly in CSS?

Yes. #2f81f7 is valid CSS and works in every current browser.

Does this HSL to HEX converter support transparency?

Alpha is preserved wherever the target notation can carry it — eight-digit hex, rgb() / a, hsl() / a and the modern CSS spaces all round-trip an alpha channel. CMYK has no alpha, so it is dropped there.

Is my color data sent anywhere?

No. Every conversion on this site runs in your browser with no network request, no account and no analytics. You can disconnect and it keeps working.