How to convert HSL to RGB
- Write S and L as fractions (50% = 0.5) and find chroma C = (1 − |2L − 1|) × S.
- X = C × (1 − |(H ÷ 60) mod 2 − 1|) and m = L − C ÷ 2.
- For hues 0–60° use (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 value, multiply by 255 and round: hsl(24, 100%, 50%) gives rgb(255, 102, 0).
Where you need RGB
Canvas drawing, image processing, LED controllers, game engines and many programming libraries work with RGB numbers. If your palette was designed in HSL, converting gives the exact channel values those tools expect.
RGB values are whole numbers, so the result is rounded. Two HSL colors that differ by a tiny amount can give the same RGB values, which simply means the difference is too small to show on a screen.
Transparency
If your color has an alpha value, such as hsla(24, 100%, 50%, 0.25), the converter gives rgba(255, 102, 0, 0.25). The alpha stays exactly the same; only the color part is converted. In the preview, transparency is shown over a checkerboard so you can see how see-through the color is.
Alpha can be written as a number from 0 to 1 or as a percentage. Both hsla(24, 100%, 50%, 0.5) and hsl(24 100% 50% / 50%) mean half transparent.
HSL in code and animations
HSL is handy for generating colors in code: stepping the hue from 0 to 360 gives a rainbow, and keeping saturation and lightness fixed gives a set of colors that look equally strong, such as the lines of a chart. Many drawing and animation libraries still expect RGB, so the last step is converting each generated color.
If you animate between two colors, interpolating in HSL keeps vivid colors bright, while interpolating in RGB can pass through a dull grey in the middle.
HSL to RGB chart of common colors
HSL to RGB values for common colors| Color | HSL | RGB |
|---|
| Black | hsl(0, 0%, 0%) | rgb(0, 0, 0) |
| White | hsl(0, 0%, 100%) | rgb(255, 255, 255) |
| Red | hsl(0, 100%, 50%) | rgb(255, 0, 0) |
| Lime | hsl(120, 100%, 50%) | rgb(0, 255, 0) |
| Blue | hsl(240, 100%, 50%) | rgb(0, 0, 255) |
| Yellow | hsl(60, 100%, 50%) | rgb(255, 255, 0) |
| Cyan | hsl(180, 100%, 50%) | rgb(0, 255, 255) |
| Magenta | hsl(300, 100%, 50%) | rgb(255, 0, 255) |
| Silver | hsl(0, 0%, 75.3%) | rgb(192, 192, 192) |
| Gray | hsl(0, 0%, 50.2%) | rgb(128, 128, 128) |
| Maroon | hsl(0, 100%, 25.1%) | rgb(128, 0, 0) |
| Olive | hsl(60, 100%, 25.1%) | rgb(128, 128, 0) |
| Green | hsl(120, 100%, 25.1%) | rgb(0, 128, 0) |
| Purple | hsl(300, 100%, 25.1%) | rgb(128, 0, 128) |
| Teal | hsl(180, 100%, 25.1%) | rgb(0, 128, 128) |
| Navy | hsl(240, 100%, 25.1%) | rgb(0, 0, 128) |
| Orange | hsl(38.8, 100%, 50%) | rgb(255, 165, 0) |
| Tomato | hsl(9.1, 100%, 63.9%) | rgb(255, 99, 71) |
Other colors: use the converter above or the Color Converter.