How this conversion is calculated
- Split the hex code into pairs: 63 66 F1.
- Convert each pair from base 16: 63 = 6 x 16 + 3 = 99.
- 66 = 6 x 16 + 6 = 102. F1 = 15 x 16 + 1 = 241.
- Scale RGB to 0 to 1: R 0.388, G 0.4, B 0.945.
- Max 0.945, min 0.388. Lightness L = (max + min) / 2 = 66.7%.
- Saturation S = (max - min) / (1 - |2L - 1|) = 83.5%.
- Hue comes from which channel is largest: H = 238.7 degrees.
- Result: hsl(239, 84%, 67%).
Code snippets
color: #6366F1;--brand: #6366F1;$brand: #6366F1;UIColor(red: 0.388, green: 0.4, blue: 0.945, alpha: 1)Color(red: 0.388, green: 0.4, blue: 0.945, opacity: 1)<color name="brand">#6366F1</color>Color(0xFF6366F1)Color.argb(255, 99, 102, 241)Color(0xFF6366F1)new Color32(99, 102, 241, 255)Color.FromArgb(255, 99, 102, 241)(99, 102, 241)Convert a list
Paste up to 1,000 values, one per line. Each line is converted to HSL.
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
Paste or pick a hex code
Enter a code such as #6366F1 in Input (HEX), or use the color picker. 3, 4, 6 and 8 digit codes work, and the # is optional.
Read the HSL result
Result (HSL) shows the comma form, with Modern CSS and Numbers only variants below it. An 8 digit hex returns hsla() and a slash alpha in the modern form.
Copy it into your CSS
Press Copy on the form your codebase uses. Numbers only gives 239, 84%, 67% for custom properties. Switch to HSL to HEX to go the other way.
Why HEX to HSL Converter
- HSL in both comma and modern space syntax.
- Keeps alpha from 8 digit hex as hsla().
- Choose 0, 1 or 2 decimal places.
- Bulk list mode and step by step math.
Hex to HSL formula with a worked example
Start with #6366F1, which is rgb(99, 102, 241). Divide by 255 to get R = 0.388, G = 0.400 and B = 0.945. The largest value is 0.945 and the smallest 0.388, a difference of 0.557.
Lightness is the average of the largest and smallest: (0.945 + 0.388) / 2 = 0.667, or 67%. Saturation is the difference divided by 1 minus the absolute value of (2 x L - 1): 0.557 / (1 - 0.333) = 0.835, or 84%. Because blue is the largest channel, hue is 60 x ((R - G) / difference + 4) = 60 x 3.979 = 239 degrees. The result is hsl(239, 84%, 67%).
| Color | HEX | HSL |
|---|---|---|
| Red | #FF0000 | hsl(0, 100%, 50%) |
| Orange | #FFA500 | hsl(39, 100%, 50%) |
| Yellow | #FFFF00 | hsl(60, 100%, 50%) |
| Green | #008000 | hsl(120, 100%, 25%) |
| Blue | #0000FF | hsl(240, 100%, 50%) |
| Purple | #800080 | hsl(300, 100%, 25%) |
| Gray | #808080 | hsl(0, 0%, 50%) |
| White | #FFFFFF | hsl(0, 0%, 100%) |