Notification
Go to Home All Tools Compare Glossary Blog Contact

RGB to HSL Converter

Paste a RGB colour and get the HSL value. Example: navy is rgb(0, 0, 128) = hsl(240, 100%, 25%). Rounding is stated, and everything runs in your browser.

Client-Side (Private)
Example colour Navy
RGB rgb(0, 0, 128)
HSL hsl(240, 100%, 25%)
Rounding Channels round half up
Live Preview
e.g. rgb(0, 0, 128)
Quick try:
Converted Result (HSL)

How to convert RGB to HSL by hand

Step-by-step mathematical method you can verify by hand

  1. Divide each channel by 255 so it runs from 0 to 1.
  2. Find the largest (max) and smallest (min) of the three and the difference Δ = max − min.
  3. Lightness L = (max + min) ÷ 2. Saturation S = Δ ÷ (1 − |2L − 1|), or 0 when Δ is 0.
  4. Hue H depends on which channel is the largest: red gives 60 × ((G − B) ÷ Δ mod 6), green gives 60 × ((B − R) ÷ Δ + 2), blue gives 60 × ((R − G) ÷ Δ + 4).

Worked example: navy (rgb(0, 0, 128))

Worked Hand Example
StepValue
R, G, B ÷ 2550, 0, 0.502
max, min, Δ0.502, 0, 0.502
L = (max + min) ÷ 225.1%
S100%
H240°
Rounded resulthsl(240, 100%, 25%)
rgb(0, 0, 128) = hsl(240, 100%, 25%) (navy).

Common colours: RGB to HSL

CSS named colours converted both ways.

ColourRGBHSL
Red rgb(255, 0, 0) hsl(0, 100%, 50%)
Orange rgb(255, 165, 0) hsl(39, 100%, 50%)
Gold rgb(255, 215, 0) hsl(51, 100%, 50%)
Green rgb(0, 128, 0) hsl(120, 100%, 25%)
Teal rgb(0, 128, 128) hsl(180, 100%, 25%)
Blue rgb(0, 0, 255) hsl(240, 100%, 50%)
Indigo rgb(75, 0, 130) hsl(275, 100%, 25%)
Purple rgb(128, 0, 128) hsl(300, 100%, 25%)
Pink rgb(255, 192, 203) hsl(350, 100%, 88%)
Brown rgb(165, 42, 42) hsl(0, 59%, 41%)
Gray rgb(128, 128, 128) hsl(0, 0%, 50%)
Black rgb(0, 0, 0) hsl(0, 0%, 0%)
White rgb(255, 255, 255) hsl(0, 0%, 100%)

Is this colour readable?

Contrast of navy (hsl(240, 100%, 25%)) against white and black (WCAG 2.x).

Text colourContrast ratioNormal text AA (4.5)Large text AA (3)
White 16.01:1 Pass Pass
Black 1.31:1 Fail Fail

Related converters

Quickly jump to other conversions and color systems

Education

About this converter

01

Exact and Explained

Paste a RGB colour and get the HSL value. Example: navy is rgb(0, 0, 128) = hsl(240, 100%, 25%). Rounding is stated, and everything runs in your browser. The worked example and tables on this page are calculated from the numbers themselves, so you can check the result by hand.

02

Privacy

The conversion runs in your browser. Nothing you type is sent to a server.

Good to know

Questions, answered

Quick answers about how this tool works.

navy is hsl(240, 100%, 25%) (in RGB: rgb(0, 0, 128)). These are CSS named colour values.

1. Divide each channel by 255 so it runs from 0 to 1. 2. Find the largest (max) and smallest (min) of the three and the difference Δ = max − min. 3. Lightness L = (max + min) ÷ 2. Saturation S = Δ ÷ (1 − |2L − 1|), or 0 when Δ is 0. 4. Hue H depends on which channel is the largest: red gives 60 × ((G − B) ÷ Δ mod 6), green gives 60 × ((B − R) ÷ Δ + 2), blue gives 60 × ((R − G) ÷ Δ + 4).

The maths is exact, but HSL and HSV values are rounded to whole numbers, so converting back can be off by 1 in a channel. Use decimals in the tool for a lossless round trip.

All of hex, rgb(), hsl(), and the newer oklch() work in current browsers. Hex is the shortest, hsl() is the easiest to adjust by hand (change only the lightness to make a shade), and oklch() gives the most even lightness steps.

Was this tool helpful?

★ 5.0 • 2 user ratings

Tap a star to rate instantly

What do you need to work out next?

Search 278+ free tools by name, or pick a category below. Every one runs instantly in your browser — no signup, nothing to install.

More Developer Tools
AI ADVISOR & COACH

Ask AI Advisor

Ask AI