HSL to RGB Color Converter

Translate intuitive HSL (Hue, Saturation, Lightness) colors into standard RGB values for web development, design systems, and digital graphics with this fast, free online tool.

HSL to RGBColor ConversionWeb ColorsCSS ColorsDeveloper Tool

Interactive HSL to RGB Converter Tool

Understanding HSL vs. RGB Color Models

HSL: The Intuitive Choice

HSL (Hue, Saturation, Lightness) is a color model designed to be more intuitive for human understanding and manipulation. It represents color using three components visualized as a cylinder:

  • Hue (H): The core color identity, represented as an angle (0-360°) on the color wheel. 0°/360° is Red, 120° is Green, 240° is Blue.
  • Saturation (S): The color's intensity or purity (0-100%). 0% is completely desaturated (grayscale), while 100% is the most vibrant version of the hue.
  • Lightness (L): The perceived brightness or luminance (0-100%). 0% is pure black, 100% is pure white, and 50% typically represents the "purest" hue without being tinted white or shaded black.

This model makes it easy to adjust specific aspects: want a lighter blue? Increase Lightness. Want a less intense green? Decrease Saturation. This aligns well with how artists and designers often think about color modification.

RGB: The Digital Standard

RGB (Red, Green, Blue) is the foundational additive color model for digital displays. It works by combining different amounts of red, green, and blue light emitted from screen pixels. Varying the intensity of each primary color channel (typically 0-255) produces the vast spectrum visible on screens.

  • Channel Values: Each of R, G, and B ranges from 0 (off) to 255 (maximum intensity).
  • Color Mixing: rgb(255, 0, 0) = Red, rgb(0, 255, 0) = Green, rgb(0, 0, 255) = Blue. Combinations like rgb(255, 255, 0) create Yellow. rgb(0, 0, 0) is Black, rgb(255, 255, 255) is White.
  • Total Colors: With 256 possibilities per channel, RGB can represent 256³, or over 16.7 million distinct colors (24-bit color).

While fundamental for screens, directly manipulating RGB values (e.g., wanting a slightly lighter red) can be less intuitive than using HSL.

How HSL to RGB Conversion Works (Conceptually)

Converting from the cylindrical HSL model to the cubic RGB model involves mathematical transformations. While the exact formulas can be complex (handling the circular nature of Hue and the relationships between Saturation, Lightness, and the RGB primaries), the core idea is to map the HSL coordinates to their corresponding position within the RGB color space.

  1. Calculate Chroma (C): This represents the color intensity relative to gray and depends on Saturation and Lightness.
  2. Determine Intermediate Values (X, m): Based on Hue and Chroma, an intermediate value (X) related to the second largest color component is found. Another value (m) represents the minimum light added to each channel, determined by Lightness and Chroma.
  3. Map Hue to RGB Sector: The Hue value (0-360°) determines which 60° sector of the color wheel the color falls into. This dictates which of R, G, or B will be the largest component (C+m), which will be the intermediate (X+m), and which will be the smallest (m).
  4. Scale to 0-255 Range: The resulting R, G, B values (initially between 0 and 1) are scaled by multiplying by 255 and then rounded to the nearest integer.

This tool handles these calculations instantly, giving you the precise RGB equivalent for any HSL input.

Why Convert HSL to RGB?

The primary reason is compatibility. While HSL is often preferred during the design and selection phase, the vast majority of digital systems rely on RGB for final output:

  • Web Development (CSS): Stylesheets primarily use RGB or HEX (which directly maps to RGB) for color definitions (e.g., color: rgb(64, 191, 191);). While CSS supports hsl() notation, converting to RGB ensures consistency and avoids potential interpretation issues.
  • Graphics Software: Many image editing and vector graphics programs internally use or require RGB values for final rendering or export for web/screen use.
  • Programming Frameworks: UI libraries and game engines often expect color inputs in RGB or RGBA format.
  • Hardware: Digital screens, cameras, and scanners are fundamentally based on capturing or displaying Red, Green, and Blue light levels.

This converter acts as a crucial bridge, allowing you to leverage the intuitive nature of HSL for design while outputting the universally compatible RGB values needed for implementation.

How to Use This HSL to RGB Converter

  1. Input HSL Values: Use the sliders provided for Hue (H), Saturation (S), and Lightness (L). Drag the sliders or click on the track. For precise control, type numeric values directly into the input boxes (Hue: 0-360, Saturation: 0-100, Lightness: 0-100).
  2. Observe Real-time Preview: As you adjust the HSL values, the color preview swatch updates instantly, displaying the resulting color.
  3. Get RGB Output: The corresponding RGB values, formatted as rgb(R, G, B) (where R, G, B are integers from 0-255), are automatically calculated and shown in the output section.
  4. Copy the RGB Code: Click the copy icon located next to the RGB output. The rgb(R, G, B) string will be copied to your clipboard, ready to paste into your CSS, code, or design documents.

HSL to RGB Code Examples (JavaScript & Python)

Implement HSL to RGB conversion directly in your projects with these code snippets:

JavaScript HSL to RGB Function


/**
 * Converts HSL color value to RGB.
 * Assumes h, s, and l are contained in the set [0, 360], [0, 100], [0, 100] respectively.
 * Returns an object {r, g, b} with values in the set [0, 255].
 *
 * @param   Number  h       The hue
 * @param   Number  s       The saturation
 * @param   Number  l       The lightness
 * @return  Object          The RGB representation
 */
function hslToRgb(h, s, l) {
  s /= 100;
  l /= 100;

  let c = (1 - Math.abs(2 * l - 1)) * s;
  let x = c * (1 - Math.abs((h / 60) % 2 - 1));
  let m = l - c / 2;
  let r = 0;
  let g = 0;
  let b = 0;

  if (0 <= h && h < 60) {
    r = c; g = x; b = 0;  
  } else if (60 <= h && h < 120) {
    r = x; g = c; b = 0;
  } else if (120 <= h && h < 180) {
    r = 0; g = c; b = x;
  } else if (180 <= h && h < 240) {
    r = 0; g = x; b = c;
  } else if (240 <= h && h < 300) {
    r = x; g = 0; b = c;
  } else if (300 <= h && h < 360) {
    r = c; g = 0; b = x;
  }
  
  r = Math.round((r + m) * 255);
  g = Math.round((g + m) * 255);
  b = Math.round((b + m) * 255);

  return { r, g, b };
}

// Example Usage:
const rgbResult = hslToRgb(180, 50, 50);
console.log(rgbResult); // Output: { r: 64, g: 191, b: 191 }
console.log(`rgb(${rgbResult.r}, ${rgbResult.g}, ${rgbResult.b})`); // Output: rgb(64, 191, 191)

Python HSL to RGB Function


import math

def hsl_to_rgb(h, s, l):
    """Converts HSL color value to RGB.
    Assumes h, s, and l are contained in the set [0, 360], [0, 100], [0, 100] respectively.
    Returns a tuple (r, g, b) with values in the set [0, 255]."""
    s /= 100.0
    l /= 100.0

    c = (1 - abs(2 * l - 1)) * s
    x = c * (1 - abs((h / 60) % 2 - 1))
    m = l - c / 2
    r, g, b = 0, 0, 0

    if 0 <= h < 60:
        r, g, b = c, x, 0
    elif 60 <= h < 120:
        r, g, b = x, c, 0
    elif 120 <= h < 180:
        r, g, b = 0, c, x
    elif 180 <= h < 240:
        r, g, b = 0, x, c
    elif 240 <= h < 300:
        r, g, b = x, 0, c
    elif 300 <= h < 360:
        r, g, b = c, 0, x

    r = round((r + m) * 255)
    g = round((g + m) * 255)
    b = round((b + m) * 255)

    return r, g, b

# Example Usage:
r_val, g_val, b_val = hsl_to_rgb(180, 50, 50)
print(f"rgb({r_val}, {g_val}, {b_val})") # Output: rgb(64, 191, 191)

Embed This HSL to RGB Tool

Integrate this converter into your own website, blog, or documentation easily using the iframe code below. It adapts to the container width.

Standard Embed Code

<iframe
    src="https://rgbatohex.com/tools/hsl-to-rgb-converter?embed=true"
    width="100%"
    height="400" 
    style="border:1px solid #ccc; border-radius:8px; overflow:hidden;"
    title="HSL to RGB Converter Tool"
  ></iframe>

Embed with Custom Initial Color

Pre-load the converter with a specific HSL color by adding h, s, and l parameters to the src URL (Hue: 0-360, Saturation: 0-100, Lightness: 0-100). Example below sets initial HSL(210, 70%, 60%):

<iframe
    src="https://rgbatohex.com/tools/hsl-to-rgb-converter?embed=true&h=210&s=70&l=60"
    width="100%"
    height="400"
    style="border:1px solid #ccc; border-radius:8px; overflow:hidden;"
    title="HSL to RGB Converter Tool (Custom Initial Color)"
  ></iframe>

Frequently Asked Questions

What is the difference between HSL and HSV/HSB?

HSL (Hue, Saturation, Lightness) and HSV/HSB (Hue, Saturation, Value/Brightness) are similar cylindrical models. The primary difference is the vertical axis: HSL's Lightness ranges from black (0%) to the pure hue (50%) to white (100%). HSV/HSB's Value/Brightness ranges from black (0%) to the pure hue (100%). This means 100% Lightness is always white, while 100% Value/Brightness is the fully saturated, bright hue itself. HSL can be more intuitive for simply making a color lighter or darker.

Is the HSL to RGB conversion perfectly accurate?

The mathematical conversion is precise. However, RGB values are stored as integers (0-255), while HSL calculations involve floating-point numbers. Rounding during the final scaling step means that converting HSL -> RGB -> HSL might result in tiny differences (often less than 1 unit). For all practical web and screen design purposes, the conversion is considered highly accurate and visually identical.

Does this tool handle transparency (Alpha)?

No, this tool specifically converts opaque HSL colors to opaque RGB colors. For colors with transparency, you would typically use the HSLA (HSL + Alpha) or RGBA (RGB + Alpha) models. Look for dedicated HSLA/RGBA converters if you need alpha channel support.

Can I convert RGB back to HSL here?

This page focuses solely on HSL → RGB. We offer a separate, dedicated RGB to HSL Converter tool for the reverse conversion.

What are the valid input ranges for HSL?

Hue (H): 0 to 360 degrees (values outside this range will typically wrap around, e.g., 370° is treated as 10°).
Saturation (S): 0% to 100%.
Lightness (L): 0% to 100%.

Ready to Convert Your HSL Colors?

Use the interactive tool above to get instant RGB values, explore the HSL color space, or grab the code examples to integrate this conversion into your own applications. Bookmark this page for quick access!

Go to Full HSL to RGB Tool