RGB to HSL Converter
This RGB to HSL Converter turns RGB (Red, Green, Blue) values into HSL (Hue, Saturation, Lightness) and HEX instantly. Built for designers, developers, and anyone working with color systems.
Last updated: September 23, 2026
Key Features
-
Real-time conversion as you adjust values
-
Dual input methods: number fields and smooth sliders
-
Live color preview shows your color immediately
-
Outputs in three formats: RGB, HSL, and Hexadecimal
-
Click-to-copy for any format, also with Enter or Space from the keyboard
-
10 preset colors for quick starting points
-
Random color generator for inspiration
-
Input validation clamps every channel to 0-255
Why Use It?
CSS supports both RGB and HSL. RGB works in absolutes (0-255 per channel). HSL thinks in human terms: pick a hue, adjust brightness, tweak saturation.
Converting between them manually is tedious. This tool does it instantly.
Perfect for:
-
CSS color conversion
-
Design system development
-
Color palette creation
-
Quick color experimentation
-
Learning color theory
Fully responsive, so it works on mobile, tablet, and desktop.
What Is an RGB to HSL Converter?
An RGB to HSL converter is a color conversion tool that takes three RGB channel values and outputs their hue, saturation, and lightness equivalents.
It removes the manual math involved in switching between RGB color values and their HSL counterparts, something designers do constantly when moving between code and design software.
Core function:
- Accepts RGB input as three integers between 0 and 255 (starting from a hex code? Run it through the HEX to RGB converter first)
- Runs the RGB to HSL formula automatically in the background
- Displays a live color swatch that updates as values change
Chrome DevTools shows this same HSL breakdown the instant you click a color swatch in the Elements panel, without needing an external converter.
Modern browsers already support the hsl() syntax natively. The classic comma-separated form has worked for well over a decade, and the newer space-separated syntax from CSS Color Module Level 4 reached Baseline widely available status in July 2022.
A converter still earns its place elsewhere, in design handoff, in scripts, and in tools that only speak RGB or hex.
What Is the Difference Between RGB, HSL, HSV and CMYK?
RGB, HSL, HSV, and CMYK all describe the same colors through different sets of numbers.
Only two of them, RGB and HSL, convert into each other through a single fixed formula.
| Model | Structure | Value range | Primary use |
|---|---|---|---|
| RGB | red, green, blue channels | 0 to 255 each | screen display, code |
| HSL | hue, saturation, lightness | 0-360°, 0-100%, 0-100% | design adjustment, theming |
| HSV/HSB | hue, saturation, value/brightness | 0-360°, 0-100%, 0-100% | photo editing, color pickers |
| CMYK | cyan, magenta, yellow, key (black) | 0-100% each | print production |
HSV, sometimes labeled HSB, gets mistaken for HSL constantly, since both use a 0-360 degree hue wheel and percentage-based saturation.
The third value is where they split. HSL's lightness runs from black through the pure hue to white, while HSV's value only runs from black to the pure hue, with no white endpoint.
Where CMYK sits apart: it's a subtractive model built for ink on paper rather than light on a screen, so an RGB to HSL converter has no direct role in CMYK color workflows.
Adobe Photoshop keeps all three, RGB, HSB, and CMYK, sitting in the same color picker precisely because print teams and screen teams need different ones.
What Do Hue, Saturation and Lightness Values Mean?
Hue, saturation, and lightness are the three numbers an RGB to HSL converter outputs, and each one controls a separate visual property.
Key figures:
- Hue: 0 to 360 degrees
- Saturation: 0 to 100 percent
- Lightness: 0 to 100 percent
- Source RGB channels: 0 to 255 each
Hue
Hue is the color's position on a 360 degree wheel, where 0 and 360 both land on red.
Landmark degrees:
- 0° and 360°: red
- 120°: green
- 240°: blue
A hue value on its own doesn't say how vivid or how bright a color looks. It only marks where the color sits on the wheel.
Saturation
Saturation controls intensity, not brightness.
- 0% saturation removes all color, leaving pure gray
- 50% saturation produces a muted, dusty version of the hue
- 100% saturation produces the most vivid version possible at that lightness
Two colors can share the exact same hue and lightness and still look completely different once saturation shifts.
Lightness
Lightness runs from black at 0% to white at 100%, with the pure hue sitting at 50%.
Why this matters: moving the lightness value up or down changes how light or dark a color looks without touching its hue or intensity.
Figma's color picker includes an HSL mode with this exact slider sitting right next to the hex input field.
How Does the RGB to HSL Conversion Formula Work?
The RGB to HSL formula converts three channel values into hue, saturation, and lightness through five sequential steps.
Every RGB to HSL converter, from browser dev tools to standalone web apps, runs some version of this same math.
- Normalize each RGB channel to a 0-1 range by dividing by 255
- Find the maximum and minimum of the three normalized values
- Calculate lightness as the average of the max and min
- Calculate saturation from the difference between max and min, relative to lightness
- Calculate hue based on which channel, red, green, or blue, holds the maximum value
The HSL model itself traces back to Joblove and Greenberg's 1978 SIGGRAPH paper on color spaces for computer graphics.
Running the tool's default color through those steps: rgb(255, 100, 150) normalizes to a max of 1.0 (red) and a min of 0.39, which gives 70% lightness, 100% saturation, and a hue of 341°, so hsl(341, 100%, 70%).
Rounding happens at the final step. Most converters round hue to the nearest whole degree, and saturation and lightness to the nearest whole percent, which is why the same color can show up as 210° in one tool and 209° in another.
Can You Convert HSL Back to RGB?
Yes, HSL converts back to RGB, though the reverse formula works differently from the original conversion.
Instead of a direct algebraic inverse, the reverse pass calculates a chroma value from saturation and lightness, then looks up RGB channels based on which 60 degree segment of the hue wheel the color falls into.
Round-trip drift: converting RGB to HSL and back to RGB can shift a color by a shade or two, since each step rounds to whole numbers.
Chroma.js runs this exact reverse formula internally whenever a script calls its RGB output method on an HSL color object.
Reverse conversion matters most at handoff. A designer working in HSL for easy lightness edits often needs the final value pushed through a separate hex conversion step before a developer can drop it into a stylesheet.
A standalone HSL to RGB converter handles this reverse pass without requiring any manual lookup table math.
When Should You Use HSL Instead of RGB?
Use HSL when you need to adjust a color's lightness or intensity by hand. Use RGB when you're matching an exact value from a brand guide or a design file.
RGB advantages:
- Matches how screens physically mix red, green, and blue light
- Exact values transfer directly from image editing software
- No conversion needed for most existing hex-based design systems
RGB drawback: lightening or darkening a color means recalculating all three channels by hand, since none of them map directly to brightness.
HSL advantages:
- One number, lightness, controls how light or dark a color looks
- Hue stays fixed while you experiment with intensity
- Easier to generate a consistent set of shades from one base color
HSL drawback: equal steps in the lightness value don't always look like equal steps to the eye, especially around yellow and blue hues.
Component libraries like shadcn/ui long shipped their entire color palette as HSL values instead of RGB, specifically so theme colors could be lightened or darkened through one variable. Its Tailwind v4 themes have since moved to OKLCH, which fixes HSL's uneven lightness.
How Does HSL Help With Accessibility and Contrast Checking?
WebAIM's 2025 audit of the top one million home pages found low contrast text on 79.1% of them, the single most common accessibility failure detected.
The Web Content Accessibility Guidelines set a minimum color contrast ratio of 4.5:1 for normal text and 3:1 for large text, based on relative luminance rather than raw color values.
HSL doesn't calculate that ratio directly. It does make one specific fix easier, adjusting lightness while leaving hue untouched.
Why lightness matters here:
- Dropping the lightness value darkens text without shifting its color identity
- Raising the lightness value on a background lightens it the same way
- Neither adjustment requires recalculating three separate RGB channels
This is the same lever behind most dark mode systems, where a single lightness pass generates a full set of accessible text and background pairs.
An accessible color palette generator automates this exact lightness-balancing process instead of leaving it to manual trial and error, and the color contrast checker confirms the final ratio.
Chrome's Lighthouse accessibility audit flags any text and background pair that falls under the 4.5:1 threshold automatically.
Which Design Tools and Platforms Support HSL Natively?
Native HSL support splits along a fairly clean line. Web-facing tools expose it directly, while traditional image editors default to HSB instead.
| Tool | Native HSL mode | Where it appears |
|---|---|---|
| Figma | Yes | Color picker toggle |
| Chrome DevTools | Yes | Elements panel swatch |
| Adobe Illustrator | No, uses HSB | Color picker sliders |
| Tailwind CSS / Sass | Indirect, via variables | Theme configuration |
Illustrator's color picker sits right next to Photoshop's in structure, offering H, S, and B fields rather than H, S, and L.
Why the distinction matters: a designer copying a "lightness" value out of Illustrator and pasting it into a CSS hsl() function is actually pasting a brightness value, and the result will not match.
Tailwind CSS takes a different approach. It doesn't offer an HSL picker mode at all, but its arbitrary value syntax lets a developer write an HSL color straight into a utility class without touching a config file.
The Tailwind CSS framework treats color this way across the board, favoring code-level flexibility over a visual picker.
How Do You Convert RGB to HSL in CSS?
Writing HSL directly in a stylesheet means passing three values into the hsl() function instead of the equivalent rgb() function.
The syntax takes a hue in degrees, then a saturation percentage, then a lightness percentage, in that fixed order.
Basic structure:
- Hue comes first, written as a plain number of degrees
- Saturation comes second, written as a percentage
- Lightness comes third, written as a percentage
- An optional fourth value adds transparency through the alpha channel
CSS custom properties have worked in every major browser since 2017, which is why storing an HSL value as a reusable variable works reliably across current browsers.
A theme built this way stores one base hue and lightness pair, then derives hover states and borders by shifting only the lightness percentage.
Sass historically offered lighten() and darken() as shortcuts for the same lightness shift. The Sass team deprecated both functions starting in Dart Sass 1.79.0, pointing developers toward color.scale() and color.adjust() instead.
What breaks without this update: a Sass file still calling lighten() keeps working for now, but it prints a deprecation warning and will fail outright once a future major Dart Sass release removes the function.
How Do You Convert RGB to HSL in JavaScript and Python?
JavaScript
JavaScript has no built-in method for this conversion. Every implementation is either hand-written or pulled from a library.
The hand-written version follows the same five steps as the manual formula: normalize the RGB values in JavaScript, find the max and min, then derive lightness, saturation, and hue in that order.
- Common bug: forgetting to divide each RGB channel by 255 before running the rest of the formula
- Common bug: leaving hue undefined when saturation is zero, since gray tones have no meaningful hue to report
D3.js runs an equivalent conversion inside its interpolateHsl module, stepping through hue, saturation, and lightness to animate smooth color transitions.
Python
Python's standard library ships a colorsys module with a built-in rgb_to_hls() function, according to the official Python documentation.
One naming detail trips people up: the function returns values in H, L, S order, not H, S, L, and every value is a float between 0 and 1 rather than degrees or percentages.
| Language | Function | Value scale |
|---|---|---|
| Python | colorsys.rgb_to_hls() | 0 to 1 floats |
| CSS | hsl() | degrees and percentages |
Converting Python's output into a CSS-ready value means multiplying the hue by 360 and the other two figures by 100 before writing them into a stylesheet.
When Does RGB to HSL Conversion Not Apply?
An RGB to HSL converter has clear limits, and pretending otherwise leads to real color mistakes.
Five situations where it doesn't help:
- Print production, where color is specified in CMYK and neither RGB nor HSL numbers transfer directly to ink
- Spot-color matching against a Pantone swatch book, matched by eye and formula rather than derived from RGB math
- Photo editing workflows built around HSB sliders, where a lightness adjustment doesn't map one-to-one onto HSL's lightness axis
- Near-white, near-black, or fully desaturated colors, where the converted hue value becomes mathematically unstable
- Legacy systems that only accept 8-bit hex codes, where HSL output still needs one further conversion step
Print sits completely outside this conversion's scope, since CMYK color values answer to ink coverage rather than to light-based RGB or HSL numbers, as the RGB vs CMYK breakdown explains.
The instability at the extremes is worth sitting with too. When saturation hits 0%, hue is undefined by the formula itself, since there's no color left to place on the wheel.
Most converters default an undefined hue to 0° rather than leaving the field blank, which can quietly mislead anyone reading the number as meaningful.
Both RGB and HSL also share the same outer boundary. Both operate inside the sRGB color space, standardized by the IEC as IEC 61966-2-1 back in 1999, so neither model can express a color that falls outside that gamut no matter how the numbers are converted.
A print vendor matching Pantone 286 C, a common corporate blue, gets a more accurate result from the physical swatch book than from any RGB-to-HSL-to-CMYK conversion chain.
FAQ on RGB to HSL Converter
Why Do RGB and HSL Round Differently Across Tools?
Rounding differences come from where a tool truncates decimals, not a different formula. Some converters round hue to the nearest degree; others keep one decimal place. The same RGB input can show as 209° in one tool and 210° in another.
What Is the Difference Between HSL and HSLA?
HSLA adds a fourth value, alpha, to the same hue, saturation, and lightness numbers. Alpha ranges from 0 to 1 and controls transparency rather than color. Modern CSS treats hsla() as an alias; hsl() itself now accepts an optional alpha channel too.
Can Hue Values Exceed 360 Degrees?
A hue value technically wraps past 360°, since the color wheel is circular. 400° and 40° point to the same color. Most converters normalize the output to the 0-360° range automatically, so a value above 360 rarely appears in practice.
Do All Browsers Support the CSS hsl() Function?
Every current major browser supports hsl(), including its comma-separated legacy syntax and the newer space-separated CSS Color Module Level 4 syntax. Internet Explorer 9 and later understood the comma syntax but never the space-separated form, so a comma-based or hex fallback still matters for legacy compatibility work.
How Accurate Are Online RGB to HSL Converters?
Browser-native conversion, through DevTools or CSS itself, is authoritative and exact. Third-party web converters run the same formula and typically match to two or three decimal places. Visible color differences from rounding are effectively imperceptible, so accuracy is rarely a practical concern.
What Should You Do First With an RGB to HSL Converter?
An RGB to HSL converter earns its keep first at the moment a base color is chosen, converting that single RGB or hex value into hue, saturation, and lightness before any shade, tint, or theme variation gets built from it.
- Pick the base color in RGB or hex
- Adjust lightness before hue when contrast is the goal
- Convert the finished value back to hex or RGB for production
WebAIM's 2025 audit found low contrast text on 79.1% of home pages, and WCAG's normal-text threshold sits at 4.5:1, a ratio built on relative luminance. HSL lightness isn't the same measurement, but raising or lowering it is the quickest way to move luminance, so adjusting lightness first fixes most failing pairs before hue or saturation get touched.
That shortcut clears the common case, not every case, trading a full contrast audit for speed. Production handoff after that step usually starts with a hex to RGB conversion when the original swatch came from a brand guide.