Convert between HSL (Hue, Saturation, Lightness) and RGB (Red, Green, Blue) color models instantly. Perfect for web design, digital art, and CSS styling.
HSL (Hue, Saturation, Lightness) and RGB (Red, Green, Blue) are two different ways to represent colors in digital design. While RGB is hardware-oriented (used by monitors and cameras), HSL is more intuitive for humans to understand and adjust.
HSL Color Model:
RGB Color Model:
HSL to RGB Conversion:
1. Convert H (0-360) to (0-1) range: h' = H / 360
2. Calculate intermediate values:
C = (1 - |2L - 1|) × S
X = C × (1 - |(h' × 6) mod 2 - 1|)
m = L - C/2
3. Determine RGB based on hue segment (0-5)
4. Add m to each component: R = (R' + m) × 255, etc.
RGB to HSL Conversion:
1. Convert RGB (0-255) to (0-1) range: r = R/255, g = G/255, b = B/255
2. Find max = max(r,g,b), min = min(r,g,b)
3. Calculate lightness: L = (max + min) / 2
4. Calculate saturation:
If max = min: S = 0
Else if L ≤ 0.5: S = (max - min) / (max + min)
Else: S = (max - min) / (2 - max - min)
5. Calculate hue:
If max = min: H = 0
Else if max = r: H = ((g - b) / (max - min)) mod 6
Else if max = g: H = (b - r) / (max - min) + 2
Else if max = b: H = (r - g) / (max - min) + 4
H = H × 60 (convert to degrees)
Web Design: HSL is often easier to work with in CSS because you can adjust lightness and saturation without changing the hue. This makes it simpler to create color variations for hover states, shadows, and gradients.
Digital Art: When painting digitally, artists often find HSL more intuitive than RGB. Adjusting the hue allows for color shifts, while saturation and lightness control intensity and brightness independently.
Data Visualization: HSL is excellent for creating color schemes where you need consistent saturation and lightness across different hues, making charts and graphs easier to read and interpret.
| Color Name | HSL | RGB | HEX |
|---|---|---|---|
| Pure Red | hsl(0, 100%, 50%) | rgb(255, 0, 0) | #ff0000 |
| Pure Green | hsl(120, 100%, 50%) | rgb(0, 255, 0) | #00ff00 |
| Pure Blue | hsl(240, 100%, 50%) | rgb(0, 0, 255) | #0000ff |
| Yellow | hsl(60, 100%, 50%) | rgb(255, 255, 0) | #ffff00 |
| Cyan | hsl(180, 100%, 50%) | rgb(0, 255, 255) | #00ffff |
| Magenta | hsl(300, 100%, 50%) | rgb(255, 0, 255) | #ff00ff |
| White | hsl(0, 0%, 100%) | rgb(255, 255, 255) | #ffffff |
| Black | hsl(0, 0%, 0%) | rgb(0, 0, 0) | #000000 |
| Gray | hsl(0, 0%, 50%) | rgb(128, 128, 128) | #808080 |
color: hsl(220, 70%, 50%); or with alpha transparency: color: hsla(220, 70%, 50%, 0.5);