Calculateus

Hex, RGB & HSL Color Converter

Convert a color between HEX, RGB and HSL formats.

Result

RGB
rgb(85, 56, 240)
HSL
hsl(249, 86%, 58%)
HEX
#5538F0

About the Color Converter

Designers and developers constantly need to translate a color between HEX, RGB, and HSL, since different tools and contexts expect different formats - our Hex, RGB & HSL Color Converter handles all three at once.

How It Works

The calculator parses your entered hex code into its red, green, and blue components, then calculates the equivalent HSL (hue, saturation, lightness) values from those RGB numbers using standard color-space conversion math.

Formula & Methodology

A 6-digit hex code directly encodes red, green, and blue as three 2-digit hexadecimal values, so extracting RGB is a simple parsing step. Converting RGB to HSL requires more work: lightness is the average of the highest and lowest of the three RGB values (normalized to a 0-1 scale), saturation depends on how far apart the highest and lowest values are relative to that lightness, and hue is determined by which of the three channels (red, green, or blue) is dominant, calculated through a piecewise formula that maps the RGB relationship onto the 360-degree hue wheel.

Step-by-Step: Calculating It By Hand

  1. 1Split the 6-digit hex code into its red, green, and blue 2-digit segments and convert each from hexadecimal to a 0-255 decimal value.
  2. 2Normalize the RGB values to a 0-1 scale and find the maximum and minimum of the three.
  3. 3Calculate lightness as the average of the max and min values.
  4. 4Calculate saturation from the spread between max and min relative to lightness, then determine hue based on which channel is dominant.

Examples

Standard conversion

The hex color #5538F0 converts to rgb(85, 56, 240) and hsl(248, 84%, 58%), showing the same color across all three formats.

Grayscale color

A perfectly neutral gray hex code converts to an RGB value with equal red, green, and blue components, and an HSL value with 0% saturation.

Advantages

  • Converts a single hex code into both RGB and HSL simultaneously
  • Uses accurate, standard color-space conversion math
  • Useful across design, development, and CSS styling contexts
  • Instant results without needing a separate tool for each format

Common Mistakes

  • Entering an invalid or incomplete hex code, like fewer than 6 digits
  • Confusing HSL's saturation and lightness percentages with RGB's 0-255 scale when reading the output
  • Forgetting that a shorthand 3-digit hex code needs to be expanded to 6 digits first
  • Assuming hue, saturation, and lightness are interchangeable with red, green, and blue when adjusting a color

Edge Cases to Watch For

  • An invalid or incomplete hex code (not exactly 6 valid hexadecimal digits) is rejected with an error rather than producing a nonsensical color.
  • A perfectly gray color (where red, green, and blue are all equal) has zero saturation and an undefined hue, which the calculation handles by defaulting hue to 0.
  • Hue is a circular value (0-360 degrees), so a raw negative intermediate result during calculation gets wrapped back into the standard positive range.
  • This accepts 6-digit hex codes, with or without a leading #; shorthand 3-digit hex codes aren't automatically expanded.

Common Use Cases

  • Converting a design tool's hex color into CSS-ready RGB or HSL syntax
  • Understanding a color's properties (hue, saturation, lightness) beyond its raw hex code
  • Cross-referencing colors between design software using different color format conventions
  • General web development and design color workflows
Written & fact-checked by the Calculateus TeamLast updated August 5, 2026How we verify our formulas

Frequently asked questions

What does HSL stand for?

Hue, Saturation, and Lightness - hue is the color's position on the color wheel (0-360°), saturation is how vivid vs. gray it is, and lightness is how light or dark it is, which many designers find more intuitive than RGB for adjusting a color.

Conclusion

Having a color instantly available in all three common formats saves a real amount of back-and-forth during design and development work. Our Random Color Generator can produce a fresh color in all three formats if you're starting a palette from scratch.