HSL to HEX Converter

HSL to HEX: hsl(210, 70%, 50%) = #2680D9. See the formula worked step by step, a reference table, and our test of every HSL value.

How to use HSL to HEX

  1. 1Enter hue (0–360), saturation and lightness (%).
  2. 2Copy the HEX code.
  3. 3Use it anywhere hsl() isn't accepted: email builders, brand portals, slide decks.

Features

  • Exact HEX for every whole-number HSL value
  • Twelve pure hues as a reference
  • Reach test: how many HEX codes HSL can name

How HSL to HEX conversion works

To write an HSL colour as HEX you rebuild the red, green and blue channels. Saturation and lightness decide how far apart the brightest and dimmest channels are (the chroma), and the hue decides which channel is brightest and where the middle one sits. Then each channel is written in base 16.

  • C = (1 − |2L − 1|) × S (chroma).
  • X = C × (1 − |(H ÷ 60) mod 2 − 1|).
  • m = L − C ÷ 2.
  • Pick (R′, G′, B′) by hue sector: 0–60°: (C, X, 0); 60–120°: (X, C, 0); 120–180°: (0, C, X); 180–240°: (0, X, C); 240–300°: (X, 0, C); 300–360°: (C, 0, X).
  • R = round((R′ + m) × 255), and likewise for G and B.
  • Write each channel as two HEX digits.

Worked example: hsl(210, 70%, 50%) to HEX

Here is the converter's own calculation for hsl(210, 70%, 50%), step by step. The result, #2680D9, is exactly what the tool above shows for this input.

  • Chroma C = (1 − |2 × 0.5 − 1|) × 0.7 = 0.7.
  • X = 0.7 × (1 − |(210 ÷ 60) mod 2 − 1|) = 0.35.
  • m = 0.5 − 0.7 ÷ 2 = 0.15.
  • 210° is in the 180–240° sector, so (R′, G′, B′) = (0, X, C) = (0, 0.35, 0.7).
  • Add m and multiply by 255: R = 38, G = 128, B = 217.
  • Red 38 = 2 × 16 + 6 → 26; green 128 = 8 × 16 + 0 → 80; blue 217 = 13 × 16 + 9 → D9.
  • Joined: #2680D9.

The twelve pure hues in HSL and HEX

Full saturation, 50% lightness, every 30° around the wheel.

ColourHSLHEX
0°hsl(0, 100%, 50%)#FF0000
30°hsl(30, 100%, 50%)#FF8000
60°hsl(60, 100%, 50%)#FFFF00
90°hsl(90, 100%, 50%)#80FF00
120°hsl(120, 100%, 50%)#00FF00
150°hsl(150, 100%, 50%)#00FF80
180°hsl(180, 100%, 50%)#00FFFF
210°hsl(210, 100%, 50%)#0080FF
240°hsl(240, 100%, 50%)#0000FF
270°hsl(270, 100%, 50%)#8000FF
300°hsl(300, 100%, 50%)#FF00FF
330°hsl(330, 100%, 50%)#FF0080

Precision test: every HSL value through the converter

Every HSL value turns into a valid HEX code, and converting that code back gives the same colour, so this direction never loses information (100% exact over all 3,672,360 whole-number HSL values). The catch is reach: those values produce only 2,037,745 distinct HEX codes, so whole-number HSL can't name most of the 16.7 million HEX colours.

Method: every whole-number HSL value, through the converter's own code and back, compared on the 0–255 scale (how we test).

MeasureResult
HSL values tested3,672,360
Distinct HEX results2,037,745
Came back exactly100%
Largest change (0–255 levels)0
Average change0

Last updated · Source: Pixohub exhaustive test of lib/color-math.ts

Where you'll use HSL to HEX

Exporting a palette you designed in HSL

Many teams design scales by stepping lightness in HSL, then export HEX for tools that don't accept hsl(), such as some email builders, older Android XML and many brand portals.

Picking evenly spaced hues

The table below walks the hue wheel in 30° steps at full saturation and 50% lightness, which gives the twelve pure hues used in most colour wheels.

Turning CSS into design-tool input

If a stylesheet uses hsl() and you need the same colour in Canva or a slide deck, HEX is the format every app accepts.

Common mistakes

  • Treating hsl(360, …) as different from hsl(0, …): both are red; hue wraps around.
  • Expecting L = 100% to give a light tint: it gives pure white whatever the hue and saturation.
  • Rounding the intermediate R′, G′, B′ before adding m, which shifts the result by one level.
  • Assuming every HEX code has a whole-number HSL twin: only about one in eight does.

Frequently asked questions

What is hsl(210, 70%, 50%) in HEX?

#2680D9. Chroma = (1 − |2 × 0.5 − 1|) × 0.7 = 0.7, the hue sits in the 180–240° sector, and the worked example above walks through each channel.

Is HSL to HEX exact?

Yes in the sense that the HEX code represents exactly the colour the converter computed; converting back gives the same colour. We confirmed this for all 3,672,360 whole-number HSL values.

Why do some HSL values give the same HEX?

Different HSL values can describe the same colour; for example every hue with S = 0% is the same grey, and at L = 0% or 100% hue and saturation stop mattering.

Can HEX include transparency from hsla()?

Yes: add a fourth pair for alpha. hsl(210 70% 50% / 0.5) is #2680D980.

More text, code & dev tools