How this conversion is calculated
- C = (1 - |2L - 1|) x S, the chroma. X = C x (1 - |(H / 60) mod 2 - 1|). m = L - C / 2.
- Pick (R, G, B) from C, X and 0 by the 60 degree sector of the hue, then add m and multiply by 255.
- Here that gives rgb(100, 103, 242).
- Red 100 = 6 x 16 + 4, so 64. Green 103 = 6 x 16 + 7, so 67. Blue 242 = 15 x 16 + 2, so F2.
- Join them after a #: #6467F2.
Code snippets
color: #6467F2;--brand: #6467F2;$brand: #6467F2;UIColor(red: 0.392, green: 0.404, blue: 0.949, alpha: 1)Color(red: 0.392, green: 0.404, blue: 0.949, opacity: 1)<color name="brand">#6467F2</color>Color(0xFF6467F2)Color.argb(255, 100, 103, 242)Color(0xFF6467F2)new Color32(100, 103, 242, 255)Color.FromArgb(255, 100, 103, 242)(100, 103, 242)Convert a list
Paste up to 1,000 values, one per line. Each line is converted to HEX.
More color formats (HWB, LAB, LCH, OKLab, XYZ and more)
Common colors reference table
Click a name to load it into the converter.
| Color | HEX | HSL | RGB |
|---|---|---|---|
| #000000 | hsl(0, 0%, 0%) | rgb(0, 0, 0) | |
| #FFFFFF | hsl(0, 0%, 100%) | rgb(255, 255, 255) | |
| #FF0000 | hsl(0, 100%, 50%) | rgb(255, 0, 0) | |
| #00FF00 | hsl(120, 100%, 50%) | rgb(0, 255, 0) | |
| #0000FF | hsl(240, 100%, 50%) | rgb(0, 0, 255) | |
| #FFFF00 | hsl(60, 100%, 50%) | rgb(255, 255, 0) | |
| #00FFFF | hsl(180, 100%, 50%) | rgb(0, 255, 255) | |
| #FF00FF | hsl(300, 100%, 50%) | rgb(255, 0, 255) | |
| #C0C0C0 | hsl(0, 0%, 75%) | rgb(192, 192, 192) | |
| #808080 | hsl(0, 0%, 50%) | rgb(128, 128, 128) | |
| #800000 | hsl(0, 100%, 25%) | rgb(128, 0, 0) | |
| #808000 | hsl(60, 100%, 25%) | rgb(128, 128, 0) | |
| #008000 | hsl(120, 100%, 25%) | rgb(0, 128, 0) | |
| #800080 | hsl(300, 100%, 25%) | rgb(128, 0, 128) | |
| #008080 | hsl(180, 100%, 25%) | rgb(0, 128, 128) | |
| #000080 | hsl(240, 100%, 25%) | rgb(0, 0, 128) | |
| #FFA500 | hsl(39, 100%, 50%) | rgb(255, 165, 0) | |
| #FF6347 | hsl(9, 100%, 64%) | rgb(255, 99, 71) | |
| #FFD700 | hsl(51, 100%, 50%) | rgb(255, 215, 0) | |
| #4B0082 | hsl(275, 100%, 25%) | rgb(75, 0, 130) |
How to use
Enter the HSL values
Type or paste into Input (HSL), for example hsl(152, 60%, 40%) or 152 60 40. You can also move the Hue, Saturation and Lightness sliders or type into their number boxes.
Check the swatch and hex
The preview swatch and Result (HEX) update as you change a value. If saturation or lightness is outside 0 to 100%, a message explains what to fix.
Copy the hex code
Press Copy on the result or on the Lowercase variant. For hsla() input, HEX without alpha gives the 6 digit version too. Use Switch to HEX to HSL for the reverse.
Why HSL to HEX Converter
- Hue, saturation and lightness sliders with number fields.
- Reads comma, modern space and bare number input.
- hsla() input returns an 8 digit hex with alpha.
- Bulk list mode, worked math and code snippets.
HSL to hex formula with a worked example
Take hsl(152, 60%, 40%). Write S = 0.6 and L = 0.4. The chroma is C = (1 - |2 x 0.4 - 1|) x 0.6 = 0.8 x 0.6 = 0.48. Next, X = C x (1 - |(152 / 60) mod 2 - 1|) = 0.48 x 0.533 = 0.256, and m = L - C / 2 = 0.16.
Hue 152 falls in the 120 to 180 band, where green is largest, so (R, G, B) = (0, C, X) = (0, 0.48, 0.256). Add m to each and multiply by 255: R = 0.16 x 255 = 41, G = 0.64 x 255 = 163 and B = 0.416 x 255 = 106. In hex that is 29, A3 and 6A, so the answer is #29A36A.
| HSL | HEX |
|---|---|
| hsl(0, 100%, 50%) | #FF0000 |
| hsl(30, 100%, 50%) | #FF8000 |
| hsl(60, 100%, 50%) | #FFFF00 |
| hsl(120, 100%, 25%) | #008000 |
| hsl(180, 100%, 50%) | #00FFFF |
| hsl(210, 100%, 50%) | #0080FF |
| hsl(240, 100%, 50%) | #0000FF |
| hsl(270, 100%, 50%) | #8000FF |
| hsl(0, 0%, 50%) | #808080 |
| hsl(152, 60%, 40%) | #29A36A |