hex-cmyk

Converter

HSL to HEX Converter

Dial in a hue, saturation and lightness and get the hex code back. Useful when a design system is defined in HSL but the handover document wants hex.

210°
100%
56%

C
M
Y
K
SUM
HEX
RGB
HSL
CMYK

Need it the other way round?HEX to HSL converter

These values are mathematical approximations. Ink, paper, press calibration and colour profile all change the printed result — always approve colour from a physical proof. Full disclaimer.

How the conversion works #

The hue wheel is divided into six 60° sectors. Which sector you land in decides which channel is at maximum, which is climbing, and which is at zero.

C = (1 − |2L − 1|) × S   // chroma X = C × (1 − |(H / 60) mod 2 − 1|) m = L − C / 2   // lightness offset     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)   add m to each, multiply by 255, convert to hex

A worked example #

hsl(210, 100%, 56%).

  1. C = (1 − |2(0.56) − 1|) × 1.0 = 0.88.
  2. H / 60 = 3.5, so 3.5 mod 2 = 1.5, and X = 0.88 × (1 − 0.5) = 0.44.
  3. m = 0.56 − 0.44 = 0.12.
  4. 210° falls in the 180–240 sector, giving (0, X, C) = (0, 0.44, 0.88).
  5. Add m: (0.12, 0.56, 1.0). Multiply by 255: (31, 143, 255).
  6. To hex: #1F8FFF.

Common HSL to hex values #

ColourHSLHEXRGB
Black0°, 0%, 0%#0000000, 0, 0
White0°, 0%, 100%#FFFFFF255, 255, 255
Red0°, 100%, 50%#FF0000255, 0, 0
Lime120°, 100%, 50%#00FF000, 255, 0
Blue240°, 100%, 50%#0000FF0, 0, 255
Yellow60°, 100%, 50%#FFFF00255, 255, 0
Cyan180°, 100%, 50%#00FFFF0, 255, 255
Magenta300°, 100%, 50%#FF00FF255, 0, 255
Dodger blue210°, 100%, 56%#1E90FF30, 144, 255
Navy240°, 100%, 25%#0000800, 0, 128
Teal180°, 100%, 25%#0080800, 128, 128
Forest green120°, 61%, 34%#228B2234, 139, 34
Olive60°, 100%, 25%#808000128, 128, 0
Orange39°, 100%, 50%#FFA500255, 165, 0
Crimson348°, 83%, 47%#DC143C220, 20, 60
Maroon0°, 100%, 25%#800000128, 0, 0
Purple300°, 100%, 25%#800080128, 0, 128
Hot pink330°, 100%, 71%#FF69B4255, 105, 180
Silver0°, 0%, 75%#C0C0C0192, 192, 192
Charcoal204°, 19%, 26%#36454F54, 69, 79

Questions #

What is chroma in this formula?

The distance between the brightest and darkest channel — effectively how much colour the result contains before lightness is applied. It is calculated first because the rest of the conversion is built on it.

Why does hue wrap at 360?

Because it is an angle on a colour wheel. 0° and 360° are both red, 380° is the same as 20°. The converter normalises anything outside the range rather than rejecting it.

Does lightness 50% always give the most vivid version?

Numerically yes: at 50% lightness with full saturation you get the pure hue. Perceptually no — a yellow at 50% lightness looks much brighter than a blue at 50% lightness, because the eye is far more sensitive to yellow-green wavelengths.

Can I skip hex and write HSL in my CSS?

Yes. Browsers accept HSL natively, and keeping colours in HSL in your stylesheet makes light and dark variants much easier to maintain. Convert to hex only when a tool or handover document demands it.