GamutDesk Logo
GamutDesk

HSL to HEX Code Converter

Convert Hue degrees, Saturation, and Lightness coordinates into standard 6-digit hexadecimal web color codes.

Client-Side ArchitecturePrivate Client-Side Processing
HSL Cylindrical Sliders
Hue (0° - 360°)
Saturation (0% - 100%)
Lightness (0% - 100%)
Generated Hex
#2463EB
Hexadecimal Value
#2463EB
Equivalent RGB:rgb(36, 99, 235)

Technical Specification & Mathematical Principles

Chroma is calculated as C = (1 - |2L - 1|) * S, followed by intermediate offset X = C * (1 - |(H / 60) mod 2 - 1|).

The resulting floating-point primary channels (R', G', B') are shifted by m = L - C / 2, multiplied by 255, and converted to base-16 hex bytes.

Frequently Asked Questions

How are intermediate chroma and lightness variables calculated?
The conversion computes chroma C = (1 - |2L - 1|) * S, secondary component X = C * (1 - |(H / 60) mod 2 - 1|), and lightness match m = L - C / 2, which then map directly to sRGB channels.
Why does 0% saturation always produce shades of gray?
When Saturation is 0%, the chroma C is zero regardless of the Hue angle. The formula outputs equal Red, Green, and Blue values, creating a neutral achromatic tone determined entirely by Lightness.
What happens if Lightness is set to 0% or 100%?
At 0% Lightness, all channels collapse to #000000 (pure black). At 100% Lightness, all channels maximize to #FFFFFF (pure white), irrespective of Hue or Saturation.

Related Design & Color Instruments