How this calculator works
Hex color codes, RGB triplets and HSL values are three different ways of writing the same color — CSS, design tools and image editors all accept them interchangeably. This calculator converts between hex and RGB in both directions and always shows the equivalent HSL value alongside.
A 6-digit hex code is three 2-digit hexadecimal (base 16) numbers back to back, one each for red, green and blue, every one ranging from 00 to FF (0 to 255 in decimal). The 3-digit shorthand form doubles each digit, so #03F is shorthand for #0033FF.
How the conversions work
Hex → RGB: split into three 2-digit hex pairs and convert each from base 16 to decimal (0-255)RGB → Hex: convert each 0-255 channel to a 2-digit base-16 pair and join themRGB → HSL: lightness L = (max + min) ÷ 2 of the normalized channels; saturation and hue follow from the spread between the largest and smallest channelHSL (hue, saturation, lightness) describes the same color as a hue angle (0-360°), a saturation percentage and a lightness percentage — often more intuitive to adjust by hand than raw RGB numbers.
Worked example: #808080 (mid-gray)
- Split into hex pairs: 80, 80, 80 — each converts from base 16 to 128 in decimal.
- RGB is therefore rgb(128, 128, 128), since all three channels are equal.
- Because red, green and blue are identical, there is no color cast: saturation is 0% and hue is undefined (shown as 0°).
- Lightness is the average of the highest and lowest channel: 128 ÷ 255 ≈ 0.502, or 50.2%, giving hsl(0,0%,50.2%).
Frequently asked questions
What does each pair of digits in a hex color mean?
A 6-digit hex code #RRGGBB has three 2-digit pairs: RR for red, GG for green, BB for blue. Each pair is a base-16 number from 00 to FF, equal to 0-255 in decimal.
What is the shorthand 3-digit hex format?
#RGB is shorthand for #RRGGBB where each digit is simply doubled — #03F means #0033FF. It only works when both digits of each pair would be identical, so it can express 4,096 colors rather than the full 16.7 million.
Why does the same color have both an RGB and an HSL value?
They describe the same color through different, mathematically equivalent axes. RGB matches how screens mix red, green and blue light; HSL matches how people tend to think about color — as a hue, how vivid it is, and how light or dark.
Is hex case-sensitive?
No. #ff0000 and #FF0000 are the same color; hex letters A-F can be written in either case.
What is the RGB value of the hex color #00FF00?
rgb(0, 255, 0) - pure green. Splitting #00FF00 into its three 2-digit pairs gives 00 for red, FF for green, and 00 for blue; converting each from base 16 to decimal gives 0, 255 and 0, the same conversion this calculator applies to any hex code, such as #808080 converting to rgb(128, 128, 128).