How does HSL to RGB conversion work?
Starting from hue, saturation, and lightness, the formula computes two intermediate values based on L and S. It then applies a piecewise function three times — once offset by 120° for each channel — mapping the circular hue scale onto separate 0–1 linear values for red, green, and blue. Those values are then scaled to 0–255.
When would you convert HSL to RGB?
HSL is great for design decisions — picking a base hue and adjusting brightness or vibrancy. But many rendering contexts, image processing libraries, and low-level APIs require RGB. This converter bridges the gap: design in HSL, output in RGB.
Common color reference
Common web colours with their RGB and HSL equivalents.
| Colour name | Hex code | RGB value | HSL value | |
|---|---|---|---|---|
| Black | #000000 | rgb(0, 0, 0) | hsl(0, 0%, 0%) | |
| White | #FFFFFF | rgb(255, 255, 255) | hsl(0, 0%, 100%) | |
| Red | #FF0000 | rgb(255, 0, 0) | hsl(0, 100%, 50%) | |
| Lime | #00FF00 | rgb(0, 255, 0) | hsl(120, 100%, 50%) | |
| Blue | #0000FF | rgb(0, 0, 255) | hsl(240, 100%, 50%) | |
| Yellow | #FFFF00 | rgb(255, 255, 0) | hsl(60, 100%, 50%) | |
| Cyan | #00FFFF | rgb(0, 255, 255) | hsl(180, 100%, 50%) | |
| Magenta | #FF00FF | rgb(255, 0, 255) | hsl(300, 100%, 50%) | |
| Electric Pink | #FF007F | rgb(255, 0, 127) | hsl(330, 100%, 50%) | |
| Silver | #C0C0C0 | rgb(192, 192, 192) | hsl(0, 0%, 75%) | |
| Gray | #808080 | rgb(128, 128, 128) | hsl(0, 0%, 50%) | |
| Maroon | #800000 | rgb(128, 0, 0) | hsl(0, 100%, 25%) | |
| Olive | #808000 | rgb(128, 128, 0) | hsl(60, 100%, 25%) | |
| Green | #008000 | rgb(0, 128, 0) | hsl(120, 100%, 25%) | |
| Purple | #800080 | rgb(128, 0, 128) | hsl(300, 100%, 25%) | |
| Teal | #008080 | rgb(0, 128, 128) | hsl(180, 100%, 25%) | |
| Navy | #000080 | rgb(0, 0, 128) | hsl(240, 100%, 25%) | |
| Indigo | #4B0082 | rgb(75, 0, 130) | hsl(275, 100%, 25%) | |
| Violet | #EE82EE | rgb(238, 130, 238) | hsl(300, 76%, 72%) | |
| Crimson | #DC143C | rgb(220, 20, 60) | hsl(348, 83%, 47%) | |
| Alice Blue | #F0F8FF | rgb(240, 248, 255) | hsl(208, 100%, 97%) |
Frequently asked questions
Why do I get slightly different numbers when converting back?
Rounding HSL values to whole numbers loses fractional precision. A round-trip may land on ±1 per channel. Store original values when precision matters.
What is the difference between HSL and HSV?
In HSL, a fully saturated color at L = 50% is a pure hue. In HSV (HSB), V = 100% at full saturation is a pure hue. They model the RGB cube differently — most CSS and web tools use HSL.