Notification
Go to Home All Tools Compare Glossary Blog Contact

HSL to HEX Converter

Paste a HSL colour and get the HEX value. Example: teal is hsl(180, 100%, 25%) = #008080. Rounding is stated, and everything runs in your browser.

Client-Side (Private)
Example colour Teal
HSL hsl(180, 100%, 25%)
HEX #008080
Rounding Channels round half up
Live Preview
e.g. hsl(180, 100%, 25%)
Quick try:
Converted Result (HEX)

How to convert HSL to HEX by hand

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

  1. Turn S and L into fractions (divide by 100). Chroma C = (1 − |2L − 1|) × S.
  2. X = C × (1 − |(H ÷ 60) mod 2 − 1|) and m = L − C ÷ 2.
  3. Pick the (R, G, B) pattern for the 60° sector of the hue: 0-60 is (C, X, 0), 60-120 is (X, C, 0), 120-180 is (0, C, X), 180-240 is (0, X, C), 240-300 is (X, 0, C), 300-360 is (C, 0, X).
  4. Add m to each, multiply by 255 and round. Then write each channel as two hex digits.

Worked example: teal (hsl(180, 100%, 25%))

Worked Hand Example
StepValue
C0.5
X0.5
m0
Sector180° to 240°
R, G, B0, 128, 128
Result#008080
hsl(180, 100%, 25%) = #008080.

Common colours: HSL to HEX

CSS named colours converted both ways.

ColourHSLHEX
Red hsl(0, 100%, 50%) #ff0000
Orange hsl(39, 100%, 50%) #ffa600
Gold hsl(51, 100%, 50%) #ffd900
Green hsl(120, 100%, 25%) #008000
Teal hsl(180, 100%, 25%) #008080
Blue hsl(240, 100%, 50%) #0000ff
Indigo hsl(275, 100%, 25%) #4a0080
Purple hsl(300, 100%, 25%) #800080
Pink hsl(350, 100%, 88%) #ffc2cc
Brown hsl(0, 59%, 41%) #a62b2b
Gray hsl(0, 0%, 50%) #808080
Black hsl(0, 0%, 0%) #000000
White hsl(0, 0%, 100%) #ffffff

Is this colour readable?

Contrast of teal (#008080) against white and black (WCAG 2.x).

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

Related converters

Quickly jump to other conversions and color systems

Education

About this converter

01

Exact and Explained

Paste a HSL colour and get the HEX value. Example: teal is hsl(180, 100%, 25%) = #008080. 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.

teal is #008080 (in HSL: hsl(180, 100%, 25%)). These are CSS named colour values.

1. Turn S and L into fractions (divide by 100). Chroma C = (1 − |2L − 1|) × S. 2. X = C × (1 − |(H ÷ 60) mod 2 − 1|) and m = L − C ÷ 2. 3. Pick the (R, G, B) pattern for the 60° sector of the hue: 0-60 is (C, X, 0), 60-120 is (X, C, 0), 120-180 is (0, C, X), 180-240 is (0, X, C), 240-300 is (X, 0, C), 300-360 is (C, 0, X). 4. Add m to each, multiply by 255 and round. Then write each channel as two hex digits.

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