ImgToColor

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.

hsl(188, 78%, 41%)
Active Color SyncHEX: #17A2B8 | RGB: rgb(23, 162, 184)
HSL CSS Stringhsl(188, 78%, 41%)
Matching HEX#17A2B8
RGB Channels (0-255)Base-10 Integers
HSL CoordinatesCylindrical Model
Quick Palette Presets:

Why Use Our Fast RGB to HSL Converter?

Intuitive Lightness Toning
Easily generate lighter tints and darker shades for UI buttons and borders by tweaking a single Lightness percentage.
Harmonized Color Wheels
Rotate Hue angles (0-360 degrees) to generate complementary, triadic, and analogous color schemes mathematically.
100% In-Browser Privacy
All algorithms run locally on your client machine with zero external analytics tracking, cookies, or remote server pings.

How to Convert RGB to HSL in 3 Simple Steps

Follow this quick process to translate decimal RGB components into intuitive HSL color coordinates.

1
Enter Red, Green, and Blue Integer Values

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.

2
Cylindrical Color Model Calculation

The conversion engine normalizes your RGB values and calculates the color wheel angle (Hue 0-360 degrees) and intensity percentages (Saturation & Lightness 0-100%).

3
Copy the CSS HSL Color Code

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.

Algorithm Steps

1. Normalize RGB channels: r = R/255, g = G/255, b = B/255.

2. Compute max, min, and delta (delta = max - min).

Lightness: L = (max + min) / 2
Saturation: S = delta === 0 ? 0 : delta / (1 - Math.abs(2*L - 1))

3. Compute Hue based on dominant channel:If max is Red: H = 60 * (((g - b) / delta) % 6)

Practical Worked Example

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°
Result: hsl(188, 78%, 41%)

Color Harmony & Cylindrical Geometry

How angular coordinate mathematics enable precise harmonic palette generation.

Color Wheel Rotation

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.

Predictable Contrast

Lightness (L) in HSL provides an immediate approximation of perceived luminance. Darkening button hover states by subtracting 8% from Lightness delivers consistent tactile feel.

Clean CSS Maintainability

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.

JavaScript / TypeScript Function
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),
  };
}
Python 3 (colorsys module)
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}
CSS Theming with HSL
: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 CSS Color Config
// 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.

PreviewColor NameHSL ValueRGB ValueHEX CodeDesign Role
Pure Redhsl(0, 100%, 50%)rgb(255, 0, 0)#FF0000Error alerts and cancel buttons
Pure Greenhsl(120, 100%, 50%)rgb(0, 255, 0)#00FF00Success states and validation
Pure Bluehsl(240, 100%, 50%)rgb(0, 0, 255)#0000FFInteractive action buttons
Pure Yellowhsl(60, 100%, 50%)rgb(255, 255, 0)#FFFF00Caution notices and warnings
Pure Cyanhsl(180, 100%, 50%)rgb(0, 255, 255)#00FFFFBright highlight badges
Pure Magentahsl(300, 100%, 50%)rgb(255, 0, 255)#FF00FFCreative accents
Ocean Cyanhsl(188, 78%, 41%)rgb(23, 162, 184)#17A2B8Primary SaaS branding
Dodger Bluehsl(210, 100%, 56%)rgb(30, 144, 255)#1E90FFActive navigation links
Tomato Coralhsl(9, 100%, 64%)rgb(255, 99, 71)#FF6347Promotional callouts
Medium Purplehsl(260, 60%, 65%)rgb(147, 112, 219)#9370DBSecondary feature cards
Lime Greenhsl(120, 61%, 50%)rgb(50, 205, 50)#32CD32Status online tags
Dark Slate Grayhsl(180, 25%, 25%)rgb(47, 79, 79)#2F4F4FFooter 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.