Notification
Go to Home All Tools Compare Glossary Blog Contact

HEX to HSL Converter

Paste a HEX colour and get the HSL value. Example: gold is #ffd700 = hsl(51, 100%, 50%). Rounding is stated, and everything runs in your browser.

Client-Side (Private)
Example colour Gold
HEX #ffd700
HSL hsl(51, 100%, 50%)
Rounding Channels round half up
Live Preview
e.g. #ffd700
Quick try:
Converted Result (HSL)

How to convert HEX to HSL by hand

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

  1. First convert the hex pairs to RGB (see hex to RGB).
  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: gold (#ffd700)

Worked Hand Example
StepValue
R, G, B ÷ 2551, 0.8431, 0
max, min, Δ1, 0, 1
L = (max + min) ÷ 250%
S100%
H50.59°
Rounded resulthsl(51, 100%, 50%)
#ffd700 = hsl(51, 100%, 50%) (gold).

Common colours: HEX to HSL

CSS named colours converted both ways.

ColourHEXHSL
Red #ff0000 hsl(0, 100%, 50%)
Orange #ffa500 hsl(39, 100%, 50%)
Gold #ffd700 hsl(51, 100%, 50%)
Green #008000 hsl(120, 100%, 25%)
Teal #008080 hsl(180, 100%, 25%)
Blue #0000ff hsl(240, 100%, 50%)
Indigo #4b0082 hsl(275, 100%, 25%)
Purple #800080 hsl(300, 100%, 25%)
Pink #ffc0cb hsl(350, 100%, 88%)
Brown #a52a2a hsl(0, 59%, 41%)
Gray #808080 hsl(0, 0%, 50%)
Black #000000 hsl(0, 0%, 0%)
White #ffffff hsl(0, 0%, 100%)

Is this colour readable?

Contrast of gold (hsl(51, 100%, 50%)) against white and black (WCAG 2.x).

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

Related converters

Quickly jump to other conversions and color systems

Education

About this converter

01

Exact and Explained

Paste a HEX colour and get the HSL value. Example: gold is #ffd700 = hsl(51, 100%, 50%). 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.

gold is hsl(51, 100%, 50%) (in HEX: #ffd700). These are CSS named colour values.

1. First convert the hex pairs to RGB (see hex to RGB). 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