Hex to RGB Color Converter
Type a hex color code to get its RGB and HSL values and see the color in a preview box. Short codes such as #f80 and codes with an alpha channel are supported.
How to use it
Type or paste a hex code with or without the leading hash. The preview updates as you type. Three-digit codes are expanded by repeating each digit, and four or eight digit codes include an alpha (opacity) value in the last position.
How it is calculated
A six-digit hex code is three pairs of base-16 digits for red, green and blue. Each pair is converted to a number from 0 to 255: the first digit times 16 plus the second digit. For HSL the channels are scaled to 0-1, lightness is (max + min) / 2, saturation is (max - min) / (1 - |2L - 1|), and hue is found from which channel is largest, giving an angle from 0 to 360 degrees.
Alpha in 8-digit hex is converted to a 0-1 value by dividing by 255 and rounding to two decimals.
Examples
#1E90FF: 1E = 30, 90 = 144, FF = 255, so rgb(30, 144, 255). In HSL that is about hsl(210, 100%, 56%).
#F80 expands to #FF8800, which is rgb(255, 136, 0).
FAQ
What does a hex color code mean?
It stores red, green and blue intensities as base-16 numbers, two digits each, from 00 (none) to FF (full).
Is the # symbol required?
No. The converter accepts the code with or without it.
What is the difference between RGB and HSL?
RGB mixes light channels. HSL describes the same color by hue angle, saturation and lightness, which is often easier to adjust by hand.
Can I convert 8-digit hex with transparency?
Yes. The last two digits are read as alpha and shown as rgba and hsla values.
See also
You may also find useful BMI Calculator.
Related calculator: Age Calculator.
More tools: Days Between Dates.
Quick online tool: Percentage Calculator.
Free and simple: Tip Calculator.