HSL to RGB Converter

°
%
%

RGB Output

Current HSL

hsl(180, 50%, 50%)
Red
128
Green
128
Blue
128
RGB
rgb(128, 128, 128)
HEX
#808080

Convert HSL colors to RGB and HEX formats instantly with our HSL to RGB Converter. This tool provides real-time color conversion with an intuitive interface.

Features

  • Live conversion - See results as you type

  • Multiple formats - Get RGB, HEX, and HSL values

  • Visual preview - Large color swatch shows your exact color

  • Copy functionality - One-click copying for all color formats

  • Responsive design - Works perfectly on desktop and mobile

How to Use

  1. Adjust the sliders or type values directly

  2. Watch the preview update in real-time

  3. Copy any format with the clipboard buttons

Input Controls

  • Hue: 0-360° (color wheel position)

  • Saturation: 0-100% (color intensity)

  • Lightness: 0-100% (brightness level)

Output Formats

  • RGB: rgb(255, 128, 0) - Perfect for CSS

  • HEX: #FF8000 - Web standard format

  • HSL: hsl(30, 100%, 50%) - Human-readable format

Built with vanilla JavaScript. No dependencies required. Clean, secure code following modern web standards.

Perfect for designers, developers, and anyone working with colors on the web.

What Is an HSL to RGB Converter?

An HSL to RGB converter is a tool or algorithm that translates a color defined by its hue, saturation, and lightness into equivalent red, green, and blue channel values.

No visual change happens during conversion. The same color gets re-expressed in a different coordinate system, one that screens and rendering pipelines can actually use.

HSL is a human-readable color model. You pick a hue angle, set how vivid the color looks, and control how light or dark it appears. RGB, by contrast, works by specifying the intensity of 3 light emitters directly. Browsers, the Canvas API, WebGL, and most image processing libraries all require RGB input to render color.

That gap is why the converter exists. Designers work in HSL. Machines render in RGB.

According to the HTTP Archive Web Almanac (2019), hex (which encodes RGB) appears on 93% of desktop pages, while HSL appears on just 1%, reflecting how widespread the need to convert HSL values into RGB-compatible formats remains in production code.

What Is the HSL Color Model?

HSL is a cylindrical color representation that organizes the sRGB color space around 3 perceptually meaningful axes: hue, saturation, and lightness.

Joblove and Greenberg formally described the HSL model in the August 1978 issue of Computer Graphics, the same publication where Alvy Ray Smith described HSV. By 1979, Tektronix had introduced graphics terminals using HSL for color designation, and the Computer Graphics Standards Committee had recommended it.

Each axis controls a distinct aspect of the color:

  • Hue: an angle between 0 and 360 degrees on the color wheel (0 = red, 120 = green, 240 = blue)
  • Saturation: intensity from 0% (gray) to 100% (fully saturated)
  • Lightness: brightness from 0% (black) to 100% (white), with 50% as the pure color

CSS has supported hsl() since around 2010, with broad browser adoption across Chrome, Firefox, Safari, Edge, and Opera 10+. The CSS Color Level 4 specification, published by the W3C, updated the syntax to allow space-separated values without commas.

How HSL Differs from HSV and HSB

Key difference: lightness at 100% in HSL always produces white, regardless of hue or saturation. In HSV/HSB, value at 100% produces the fully saturated color, not white.

This distinction matters when converting. Adobe Photoshop uses HSB internally, not HSL. A color at HSB(210, 50%, 100%) and HSL(210, 50%, 75%) look similar but produce different RGB output values. Treating one model as the other is a common source of conversion errors.

ModelMax value producesUsed in
HSLWhite at L=100%CSS, web design, color theory
HSV / HSBBright color at V=100%Photoshop, Sketch, legacy tools

What Is the RGB Color Model?

RGB is an additive color model where red, green, and blue light combine to produce a visible color. Each channel holds a value from 0 to 255 in standard 8-bit color, giving 16,777,216 possible combinations.

Combining all 3 channels at full intensity (255, 255, 255) produces white. All 3 at zero produce black. This is the opposite of how ink mixing works, which is why print workflows use CMYK instead.

RGB output devices include LCD monitors, OLED screens, projectors, and LED displays. The sRGB color profile, the standard for web content, defines exactly which physical colors those numeric values correspond to on a calibrated display.

CSS accepts RGB via 3 notations:

  • rgb(255, 0, 0) — legacy comma syntax
  • rgb(255 0 0) — modern space-separated syntax (CSS Color Level 4)
  • #FF0000 — hex encoding of the same values

For WebGL, values must be normalized to a 0.0-1.0 float range. rgb(255, 0, 0) becomes vec3(1.0, 0.0, 0.0). The Canvas API's fillStyle property accepts both rgb() strings and hex, but not HSL in older environments.

What Is the HSL to RGB Conversion Formula?

The standard algorithm comes directly from the CSS Color Level 4 specification published by the W3C. It converts normalized HSL coordinates (each scaled to a 0-1 range) into RGB values, then scales the result back to 0-255.

The formula works by calculating chroma (C), an intermediate value (X), and a match value (m) that shifts the output to the correct lightness level. These 3 values map the hue sector to the correct RGB channel assignment.

VariableFormulaPurpose
C (Chroma)(1 -2L - 1) \* SColor intensity before lightness offset
X (Intermediate)C \* (1 -H/60 mod 2 - 1)Secondary channel value per hue sector
m (Match)L - C/2Lightness offset added to each channel

The hue circle is split into 6 sectors of 60 degrees each. Each sector maps C and X to different (R, G, B) positions, which is how the formula handles all hue values from 0 to 360.

Step-by-Step Conversion Process

Process flow:

  1. Normalize: divide H by 360, S by 100, L by 100
  2. Calculate chroma C = (1 - |2L - 1|) \* S
  3. Calculate X = C \* (1 - |H/60 mod 2 - 1|)
  4. Assign pre-shift (R1, G1, B1) based on which 60-degree sector H falls in
  5. Calculate m = L - C/2
  6. Add m to each channel, multiply by 255, round to integer

The rounding step matters. Truncating instead of rounding introduces up to a 0.5/255 error per channel. At the boundaries between sectors, this produces a visibly different color in some cases.

Edge Cases in the Formula

3 edge cases need explicit handling. Most conversion bugs come from ignoring them.

Saturation = 0: all 3 channels equal L \* 255. The result is always a gray, regardless of the hue value.

Lightness = 0: output is always rgb(0, 0, 0). No hue or saturation value changes this.

Lightness = 100%: output is always rgb(255, 255, 255). Again, hue and saturation are irrelevant. And hue values of 360 and 0 are treated as identical — both map to red.

How to Convert HSL to RGB Manually?

Worked example: HSL(210, 50%, 60%)

Step 1 — Normalize: H = 210/360 = 0.583, S = 0.5, L = 0.6

Step 2 — Chroma: C = (1 - |2(0.6) - 1|) \ 0.5 = (1 - 0.2) \ 0.5 = 0.4

Step 3 — H' = 210/60 = 3.5. X = 0.4 \ (1 - |3.5 mod 2 - 1|) = 0.4 \ (1 - |1.5 - 1|) = 0.4 \* 0.5 = 0.2

Step 4 — H' falls in sector 3 (between 3.0 and 4.0), so (R1, G1, B1) = (0, X, C) = (0, 0.2, 0.4)

Step 5 — m = 0.6 - 0.4/2 = 0.4. Final: R = (0 + 0.4) \ 255 = 102, G = (0.2 + 0.4) \ 255 = 153, B = (0.4 + 0.4) \* 255 = 204

Result: rgb(102, 153, 204) — a medium steel blue.

The 2 most common manual errors: rounding intermediate values before the final step (introduces compounding error), and forgetting to normalize S and L from percentage to decimal before calculating chroma.

How to Convert HSL to RGB in Code?

Implementation differs across environments. The math is identical, but argument order, input ranges, and output formats vary by language and library.

JavaScript

3 approaches available in JS:

  • Pure function using the CSS Color 4 algorithm directly
  • Browser trick: assign an hsl() string to a canvas element's fillStyle, then read back computedStyle to get the browser-resolved rgb() value
  • chroma.js (version 2.4.2): chroma('hsl(210, 50%, 60%)').rgb() returns [102, 153, 204]

The browser trick is handy for quick debugging but relies on the DOM being available. Not usable in Node.js or service workers without a polyfill.

Python

Python's standard library includes colorsys.hls_to_rgb(). Watch out: the argument order is H, L, S, not H, S, L. This catches people off guard constantly.

The function returns float values between 0.0 and 1.0. Multiply by 255 and round to get standard 8-bit output. PIL/Pillow also handles this internally when converting between color modes, but exposes the values in 0-255 integer form.

CSS

CSS renders hsl() natively. No explicit conversion to rgb() is needed for styling.

When you do need the numeric RGB values (for canvas work, accessibility contrast checks, or exporting to another system), the MDN-documented method is to use getComputedStyle() after applying the hsl() value to an element. The browser returns the resolved rgb() string.

CSS Color Level 4 also introduced oklch and oklab as perceptually uniform alternatives. For serious design system work, oklch produces more consistent lightness steps across hues than HSL does — a known limitation of the HSL model that Evil Martians documented in detail in their 2022 analysis.

What Are the Common HSL to RGB Conversion Errors?

Most bugs in HSL to RGB conversion come from 4 recurring mistakes. All of them are tricky in exactly the same way: the output looks plausible, just slightly wrong.

Argument order in Python's colorsys: hls_to_rgb(h, l, s) not hls_to_rgb(h, s, l). The function name even lists them in the wrong order relative to the model's name. Every developer hits this at least once.

Hue out of range: values above 360 or below 0 must be wrapped using modulo before running the formula. An unwrapped hue of 400 maps to the wrong sector and produces incorrect output.

Scale mismatch: mixing 0-255 integer values and 0-1 float values in the same function breaks the chroma and intermediate calculations. The formula assumes fully normalized input.

Rounding timing: applying Math.round() or Math.floor() to intermediate values before the final multiply-by-255 step compounds the error. Round only at the very end, after adding m and multiplying by 255.

How Does HSL to RGB Conversion Work in Design Tools?

Design tools handle HSL to RGB conversion internally. The color model you pick in the UI affects how you input values, not how the tool renders or exports them.

Figma supports 5 color models in its color picker: Hex, HSB, HSL, CSS, and RGB. Switching between them doesn't change how Figma renders the color, only how it describes it (Figma Help Center, 2024).

ToolSupports HSL inputInternal modelExport format
FigmaYes (via color picker)sRGBHex, RGB, CSS
Adobe PhotoshopNo (uses HSB)HSB / sRGBHex, RGB
SketchNo (uses HSB)HSB / sRGBHex, RGB
Chrome DevToolsYessRGBHSL, RGB, Hex

Photoshop and Sketch both use HSB internally, not HSL. A color at HSB(210, 50%, 80%) and HSL(210, 50%, 65%) look similar in the picker but produce different RGB output values. This trips up developers pulling color values directly from design files.

Chrome DevTools handles this cleanly. Clicking the color swatch in the inspector cycles through HSL, RGB, and hex representations of the same computed value, letting you verify the browser's actual rendering of any hsl() string.

What Is the Difference Between HSL to RGB and HSL to Hex Conversion?

Hex is RGB. The only difference is encoding: hex expresses the same 3 channel values in base-16 notation instead of decimal.

rgb(102, 153, 204) and #6699CC describe the exact same color. Converting HSL to hex requires the same RGB formula first, then a second step to convert each 0-255 integer into its 2-digit hexadecimal equivalent.

When to Use Hex vs RGB Output

Hex: shorter for static values, universally supported in CSS, HTML attributes, and SVG.

rgb(): easier to manipulate programmatically. You can do arithmetic on individual channels without parsing a string.

WizlyTools (2026) confirms conversion between sRGB formats (hex, rgb, hsl) is lossless. No color data is lost when moving between these 3 notations, provided you round correctly at the final step.

Alpha Channel Handling

The 6-digit hex format has no alpha channel. hsla(210, 50%, 60%, 0.5) converts to rgba(102, 153, 204, 0.5), not to a 6-digit hex code.

8-digit hex (#6699CC80) does support alpha, using the same base-16 encoding for the 4th channel. Browser support for 8-digit hex is solid across all modern browsers as of 2017.

How to Use an Online HSL to RGB Converter?

Most online converters work the same way: 3 input fields for H, S, and L, plus an output panel showing R, G, B values and the hex equivalent.

A few reliable tools worth bookmarking:

  • CSS Portal's color converter (supports HSL, RGB, Hex, HSV, LAB, OKLCH, and CMYK in one interface)
  • colordesigner.io (clean interface, exports in 6 formats)
  • w3schools.com color converter (quick reference, good for sanity-checking values)

You can also use the browser console as a free converter. Assign an hsl() string to any element's style in DevTools and read back the computed rgb() value. No tool needed.

What to Look for in a Reliable Converter

Not all converters handle the algorithm correctly. 3 red flags to watch for:

HSB mislabeled as HSL: the most common problem. If S=100% and L=50% doesn't produce a fully saturated color, the tool is using HSB math.

No edge case handling: enter S=0 and any hue value. The output should always be a gray (R=G=B). If it isn't, the formula is broken.

No hex output: a converter that only shows RGB values without the hex equivalent makes it harder to verify the result against other tools or use it directly in code.

Our HSL to RGB converter handles all 3 of these correctly, including proper edge case behavior and both RGB and hex output.

What Are the Practical Applications of HSL to RGB Conversion?

HSL is the preferred model for color authoring. RGB is what production environments actually consume. The conversion sits at that boundary.

WebAIM's 2024 Million analysis found that 80.3% of the top 1 million websites have detectable color contrast failures, the most common accessibility error. Most contrast-checking tools require RGB or hex input to run the WCAG luminance formula.

Canvas API and WebGL

The Canvas API's fillStyle accepts hsl() strings in modern browsers, but WebGL does not.

WebGL requires normalized 0.0-1.0 float values per channel. A design color at HSL(210, 50%, 60%) must be converted to RGB(102, 153, 204) then divided by 255 to get vec3(0.4, 0.6, 0.8) before passing it to a shader. Three.js wraps this internally via its Color class, but you still need the RGB values as the starting point.

Color Palette Generation

HSL is the standard model for generating tints, shades, and hue-shifted color palettes programmatically. You work in HSL, then convert to RGB (or hex) for export.

Stripe built its previous color system in Lab space with a custom visualization tool to fine-tune each shade. Most teams use HSL instead because the arithmetic is simpler. Adjust lightness in even increments, shift the hue by 30 to 60 degrees for harmonious variants, then run the conversion formula to get production-ready hex values for design tokens.

Accessibility Contrast Checking

The WCAG relative luminance formula requires linear RGB values, not sRGB integers or HSL.

The formula is: L = 0.2126 \ R\linear + 0.7152 \ G\linear + 0.0722 \* B\_linear. Each channel must first be gamma-decoded from the sRGB value. Green carries the most weight (0.7152) because human vision is most sensitive to green wavelengths. Blue carries the least (0.0722). This is why HSL lightness is perceptually inconsistent across hues: a blue and a yellow at the same HSL lightness value produce very different luminance values in the WCAG formula.

Image Processing Pipelines

PIL/Pillow, OpenCV, and Sharp all work in RGB color space. Any programmatic color manipulation done in HSL must be converted before being written to an image.

Sharp (the Node.js image library) processes pixels in sRGB by default. When applying tint overlays or adjusting brand colors across a batch of images, the standard workflow is: define the color in HSL for readability, convert to RGB for the processing step, apply the transformation, and save.

How Does HSL to RGB Conversion Affect Color Accuracy?

Converting between HSL and RGB within the sRGB color space is mathematically lossless. WizlyTools (2026) confirms no color data is lost in the conversion itself.

The accuracy issue isn't the formula. It's what happens after: integer rounding.

Rounding Error and Round-Trip Accuracy

Each channel introduces up to 0.5/255 of error (~0.2%) when the float result is rounded to an 8-bit integer.

Round-trip conversion (HSL to RGB back to HSL) doesn't always return the original HSL values. A W3C CSS working group analysis found that rounding RGB to integer at intermediate steps causes HSL values to drift on the return trip. Storing colors as 16-bit floats per channel avoids this, but standard web color pipelines use 8-bit integers.

sRGB vs Linear RGB

sRGB is gamma-encoded. Linear RGB is not. The same numeric values produce different visual results depending on which color profile the rendering environment assumes.

sRGB: used by CSS, PNG, JPEG, most screens. Gamma-encoded for perceptual uniformity at 8-bit depth.

Linear RGB: used by WebGL shaders, HDR pipelines, WCAG contrast formula. Each channel must be gamma-decoded before use.

Passing sRGB channel values directly into a WebGL shader that expects linear RGB produces washed-out, incorrect colors. The conversion step is: divide by 255, then apply inverse gamma correction before feeding the value to the shader.

When Float Precision Matters

For most web UI work, 8-bit integer RGB is sufficient. The rounding error is invisible at normal viewing distances.

For HDR displays, accessibility tools, or anything doing per-pixel arithmetic across many steps, use floating-point RGB (0.0 to 1.0). OKLCH, supported in all modern browsers since May 2023, offers perceptually uniform lightness and is the better starting point for systems where HSL's lightness inconsistency causes problems. For related color conversion tools, see our RGB to HEX converter, HEX to RGB converter, and RGB to CMYK converter.

Understanding the full range of color theory behind these models helps when deciding which format suits a given production context. The saturation and hue components that make HSL intuitive for designers are also the reason the model needs conversion at the rendering stage. Working with color palettes or checking color contrast both depend on accurate HSL to RGB conversion at some point in the workflow.

FAQ on HSL to RGB Converters

What is an HSL to RGB converter?

An HSL to RGB converter is a tool or algorithm that translates hue, saturation, and lightness values into red, green, and blue channel output. Browsers and rendering pipelines require RGB. The converter bridges how designers describe color and how machines display it.

Why do I need to convert HSL to RGB?

CSS renders hsl() natively, but WebGL, the Canvas API, PIL, OpenCV, and most image processing libraries require RGB input. Color conversion is necessary any time your pipeline moves outside the browser's stylesheet engine.

Is the HSL to RGB conversion formula accurate?

Yes. The conversion formula from the CSS Color Level 4 specification is mathematically exact within the sRGB color space. The only accuracy loss comes from rounding the float result to 8-bit integers at the final step.

Does converting HSL to RGB change the color?

No. The color stays identical. Only the coordinate system changes. HSL and RGB are two different ways to describe the same sRGB color space. No visual difference occurs during a correct color space transform.

What is the HSL to RGB conversion formula?

Normalize H (divide by 360), S and L (divide by 100). Calculate chroma C = (1 - |2L - 1|) \* S. Derive intermediate value X and match value m. Assign channels by hue sector, add m, multiply by 255.

How do I convert HSL to RGB in JavaScript?

Write a pure function using the CSS Color 4 algorithm, use chroma.js (chroma('hsl(210,50%,60%)').rgb()), or assign the hsl() string to a canvas fillStyle and read back the computed rgb() value via getComputedStyle.

How do I convert HSL to RGB in Python?

Use Python's built-in colorsys.hls_to_rgb(h, l, s). Watch the argument order carefully: it takes H, L, S, not H, S, L. Multiply the 0-1 float output by 255 and round to get standard 8-bit RGB values.

What is the difference between HSL to RGB and HSL to hex?

Hex is just RGB encoded in base-16. Converting HSL to hex requires the same RGB conversion first, then a second step to express each 0-255 integer as a 2-digit hexadecimal value. The underlying color data is identical.

What are common errors in HSL to RGB conversion?

4 recurring mistakes: using HSB values instead of HSL, hue values above 360 without modulo wrapping, mixing 0-255 and 0-1 scale inputs, and rounding intermediate values before the final multiply-by-255 step. Round only at the end.

Does HSL to RGB work for all colors?

Yes, for all colors within the sRGB gamut. HSL and RGB both describe the same sRGB color space. Wide-gamut colors from Display P3 or rec2020 cannot be accurately represented in either format without clipping to the nearest sRGB equivalent.