Skip to content

HSL to HEX Color Converter

Free

Convert HSL color values to HEX. Enter hsl(217, 91%, 60%), get #3B82F6. Free, runs in your browser, no signup.

hsl color to hexconvert hsl to hex codehsl to hex online
All Color Tools

Settings guide

Input format flexibility:

InputExampleNotes
CSS hsl()hsl(217, 91%, 60%)Parsed directly
Space-separatedhsl(217 91% 60%)Modern CSS syntax, also accepted
Raw values217, 91, 60Enter H/S/L fields separately
With alphahsla(217, 91%, 60%, 0.5)Outputs 8-digit HEX

Common HSL → HEX reference:

HSLHEXColor
hsl(0, 100%, 50%)#FF0000Red
hsl(120, 100%, 50%)#00FF00Green
hsl(240, 100%, 50%)#0000FFBlue
hsl(0, 0%, 0%)#000000Black
hsl(0, 0%, 100%)#FFFFFFWhite
hsl(0, 0%, 50%)#808080Mid gray

Format comparison

HSL vs HEX for design tokens: HEX wins for final output — it's what design tools export, what CSS frameworks expect, and what's most compact. HSL wins for generation — building color scales, theming, and dark-mode variants is far easier in HSL. The practical workflow: work in HSL, store as HEX.

HSL vs RGB as an intermediate: RGB is the mathematical bridge between HSL and HEX (all conversions go HSL→RGB→HEX). There's no reason to keep RGB as your working format — HSL is more human-readable, and HEX is more tool-compatible.

HSL vs CSS relative colors: CSS Color Level 4 introduces relative colors like hsl(from var(--primary) calc(h + 30) s l). This makes it possible to derive palette variants in CSS without any conversion at all. For modern projects targeting 2025+ browser support, this eliminates the need to convert HSL to HEX for derived colors.

How it works

1

Enter HSL

Paste a CSS hsl() value or enter H, S, L separately. Alpha optional.

2

Convert

HSL is converted to RGB, then each channel is formatted as a two-digit HEX string.

3

Copy

Click the HEX output to copy — uppercase or lowercase, with or without the #.

About this format

HSL to HEX conversion is the final step when you've been working with color adjustments in HSL and need the HEX value for a stylesheet, design tool, or asset export. HSL is excellent for building and adjusting colors — you manipulate hue, saturation, and lightness intuitively — but most CSS frameworks, design tools, and output formats expect HEX.

This conversion is also the output step when building automated color scales. If you generate a 10-step shade scale by stepping L from 10% to 90% in HSL, you need the HEX values to put into a design system token file, a Tailwind config, or a CSS custom property list.

The conversion algorithm goes HSL → RGB → HEX. Each HSL combination maps to exactly one RGB triplet, which maps to exactly one HEX string. The only imprecision comes from rounding intermediate floating-point values — differences are sub-pixel and visually invisible.

Frequently asked questions

Why does hsl(0, 0%, 50%) not look like a pure gray?+
It should be #808080, which is pure mid-gray. If it looks warm or cool, your monitor's color profile or ambient lighting is influencing perception. The conversion itself is mathematically correct.
What HSL value represents white and black?+
Black is hsl(0, 0%, 0%) — hue and saturation are irrelevant at 0% lightness. White is hsl(0, 0%, 100%). Any hue with 0% saturation and 50% lightness gives mid-gray (#808080). For pure grays, set saturation to 0% and vary lightness.
Can I convert an HSLA value with transparency?+
Yes. The alpha value (0–1) is converted to the 0–255 range, formatted as a hex pair, and appended to the 6-digit HEX to produce an 8-digit result. hsla(217, 91%, 60%, 0.5) → #3B82F67F (7F ≈ 127 = 50% of 255).
Is the HSL to HEX conversion perfectly reversible?+
Almost. Floating-point rounding means the round-trip #HEX → HSL → #HEX can occasionally produce a value off by 1 in one channel (e.g., #3B82F6 vs #3B82F5). The difference is 1/255 per channel — completely imperceptible. Use the original HEX when precision matters.
What is the correct way to write HSL in modern CSS?+
Modern CSS (Color Level 4) uses space-separated syntax: hsl(217 91% 60%) instead of hsl(217, 91%, 60%). For transparency: hsl(217 91% 60% / 0.5) instead of hsla(217, 91%, 60%, 0.5). Both the old and new syntaxes work in all modern browsers.

Related tools and guides