RGB to HSL Converter
Convert RGB color values to cylindrical HSL with step-by-step mathematical decomposition, W3C CSS Level 3/4 syntax, and Tailwind arbitrary class exports.
hsl(221deg 83% 53%)
Technical Specification & Mathematical Principles
Step-by-Step Algebraic Decomposition (RGB to HSL)
Converting non-linear sRGB coordinates into the cylindrical HSL (Hue, Saturation, Lightness) color space follows five deterministic algebraic steps:
Scale integer byte coordinates from [0, 255] to real values [0.0, 1.0]:
R' = R / 255, G' = G / 255, B' = B / 255Identify the maximum and minimum channel components and calculate chromatic span (Delta Δ):
C_max = max(R', G', B')C_min = min(R', G', B')Δ = C_max - C_minLightness represents the average of the most and least luminous channels:
L = (C_max + C_min) / 2If Δ = 0, the color is achromatic gray with S = 0%. Otherwise, saturation scales relative to maximum available chroma at lightness L:
S = Δ / (1 - |2L - 1|) = Δ / (2 - C_max - C_min) [for L > 0.5]S = Δ / (C_max + C_min) [for L ≤ 0.5]Hue is evaluated across six 60-degree sextants depending on which color channel is maximal:
If Δ = 0: H = 0°If C_max = R': H = 60° × (((G' - B') / Δ) mod 6)If C_max = G': H = 60° × (((B' - R') / Δ) + 2)If C_max = B': H = 60° × (((R' - G') / Δ) + 4)If H < 0°: H = H + 360°Need adjacent palette tones? Explore 30-degree hue offsets with our tool for analogous color harmonies.
Frequently Asked Questions
Why does the algorithm evaluate max and min channels first?
How is Hue calculated when multiple channels are equal?
What is the difference between CSS Level 4 and Level 3 HSL syntax?
Can I use Tailwind CSS arbitrary values for HSL colors?
Related Design & Color Instruments
HEX to RGB Converter
Convert hexadecimal web color strings (#RRGGBB) to decimal integer rgb(r, g, b) tuples instantly.
RGB to HEX Converter
Convert decimal RGB integer components (0-255) to uppercase 6-digit padded hexadecimal strings.
HEX to HSL Converter
Convert hexadecimal color codes to CSS HSL and HSLA cylindrical coordinates with step-by-step algebraic formula breakdowns.
HSL to HEX Converter
Transform cylindrical HSL coordinates into standardized 6-digit hexadecimal web color strings.