RGB to HSL Converter
RGB to HSL converter translates Red, Green, and Blue decimal color values into intuitive Hue, Saturation, and Lightness (HSL) coordinates in real time. Effortlessly create dynamic color palettes, harmonized hover states, and scalable CSS design systems with human-friendly color adjustments.
Why Use Our Fast RGB to HSL Converter?
How to Convert RGB to HSL in 3 Simple Steps
Follow this quick process to translate decimal RGB components into intuitive HSL color coordinates.
Input your Red (R), Green (G), and Blue (B) decimal numbers ranging from 0 to 255 into their corresponding channel fields. Each number represents 8 bits of light intensity.
The conversion engine normalizes your RGB values and calculates the color wheel angle (Hue 0-360 degrees) and intensity percentages (Saturation & Lightness 0-100%).
Click the Copy button to immediately grab the formatted hsl(H, S%, L%) code for styling UI buttons, hover tints, and dynamic design token palettes.
Understanding the RGB to HSL Conversion Algorithm
Learn the exact geometric projection used to map the RGB color cube onto a double-hexcone cylindrical model.
1. Normalize RGB channels: r = R/255, g = G/255, b = B/255.
2. Compute max, min, and delta (delta = max - min).
3. Compute Hue based on dominant channel:If max is Red: H = 60 * (((g - b) / delta) % 6)
Converting rgb(23, 162, 184) into HSL:
- Normalized: r=0.090, g=0.635, b=0.722
- Extremes: max=0.722 (Blue), min=0.090, delta=0.632
- Lightness: (0.722 + 0.090) / 2 = 40.6%
- Saturation: 0.632 / (1 - |2*0.406 - 1|) = 77.8%
- Hue (Blue max): 60 * ((0.090 - 0.635) / 0.632 + 4) = 188°
Color Harmony & Cylindrical Geometry
How angular coordinate mathematics enable precise harmonic palette generation.
Because Hue is an angle (0° to 360°), adding 180° creates complementary colors, while +/-120° yields perfect triadic color harmonies across your web application interface.
Lightness (L) in HSL provides an immediate approximation of perceived luminance. Darkening button hover states by subtracting 8% from Lightness delivers consistent tactile feel.
Using CSS custom properties with HSL components enables instant site-wide theme switching (e.g. changing brand Hue from blue to purple with a single CSS variable update).
RGB to HSL Code Implementations
Robust algorithms for JavaScript, TypeScript, Python, and CSS variables.
function rgbToHsl(r: number, g: number, b: number): { h: number; s: number; l: number } {
r /= 255; g /= 255; b /= 255;
const max = Math.max(r, g, b), min = Math.min(r, g, b);
let h = 0, s = 0;
const l = (max + min) / 2;
if (max !== min) {
const d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch (max) {
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
case g: h = (b - r) / d + 2; break;
case b: h = (r - g) / d + 4; break;
}
h /= 6;
}
return {
h: Math.round(h * 360),
s: Math.round(s * 100),
l: Math.round(l * 100),
};
}import colorsys
def rgb_to_hsl(r: int, g: int, b: int):
h, l, s = colorsys.rgb_to_hls(r / 255.0, g / 255.0, b / 255.0)
return {
"h": round(h * 360),
"s": round(s * 100),
"l": round(l * 100)
}
# Example:
print(rgb_to_hsl(23, 162, 184)) # {'h': 188, 's': 78, 'l': 41}:root {
--primary-h: 188;
--primary-s: 78%;
--primary-l: 41%;
}
.btn-primary {
background: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
}
.btn-primary:hover {
/* Effortless 10% lighter hover state */
background: hsl(var(--primary-h), var(--primary-s), calc(var(--primary-l) + 10%));
}// tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
brand: {
light: 'hsl(188, 78%, 65%)',
DEFAULT: 'hsl(188, 78%, 41%)',
dark: 'hsl(188, 78%, 25%)',
}
}
}
}
}RGB to HSL Color Reference Chart
Quick lookup table showing standard primary, secondary, and tertiary web colors with their exact HSL and RGB coordinates.
| Preview | Color Name | HSL Value | RGB Value | HEX Code | Design Role |
|---|---|---|---|---|---|
| Pure Red | hsl(0, 100%, 50%) | rgb(255, 0, 0) | #FF0000 | Error alerts and cancel buttons | |
| Pure Green | hsl(120, 100%, 50%) | rgb(0, 255, 0) | #00FF00 | Success states and validation | |
| Pure Blue | hsl(240, 100%, 50%) | rgb(0, 0, 255) | #0000FF | Interactive action buttons | |
| Pure Yellow | hsl(60, 100%, 50%) | rgb(255, 255, 0) | #FFFF00 | Caution notices and warnings | |
| Pure Cyan | hsl(180, 100%, 50%) | rgb(0, 255, 255) | #00FFFF | Bright highlight badges | |
| Pure Magenta | hsl(300, 100%, 50%) | rgb(255, 0, 255) | #FF00FF | Creative accents | |
| Ocean Cyan | hsl(188, 78%, 41%) | rgb(23, 162, 184) | #17A2B8 | Primary SaaS branding | |
| Dodger Blue | hsl(210, 100%, 56%) | rgb(30, 144, 255) | #1E90FF | Active navigation links | |
| Tomato Coral | hsl(9, 100%, 64%) | rgb(255, 99, 71) | #FF6347 | Promotional callouts | |
| Medium Purple | hsl(260, 60%, 65%) | rgb(147, 112, 219) | #9370DB | Secondary feature cards | |
| Lime Green | hsl(120, 61%, 50%) | rgb(50, 205, 50) | #32CD32 | Status online tags | |
| Dark Slate Gray | hsl(180, 25%, 25%) | rgb(47, 79, 79) | #2F4F4F | Footer and dark surfaces |
Frequently Asked Questions About RGB to HSL
Discover best practices for color manipulation, algorithmic conversions, and responsive CSS styling.
Explore Related Color Conversion Tools
Switch seamlessly between web color spaces with our free online tools.