HEX to RGB Converter

Pick a color visually or type any format - HEX, RGB or HSL - and get all formats instantly.

How HEX and RGB relate

A HEX color code is simply RGB values written in hexadecimal. #FF5733 means red 255, green 87, blue 51 - the same three numbers, in base 16 instead of base 10.

#FF5733
  FF = 255 (red)
  57 = 87 (green)
  33 = 51 (blue)

rgb(255, 87, 51)

Hexadecimal is used because two hex digits express exactly the range 0-255 in a fixed width, which makes a color a tidy six characters rather than a variable-length list of numbers.

Key takeaways

  • Each pair of hex digits is one color channel, 00 to FF (0 to 255).
  • Three-digit shorthand doubles each digit: #F53 means #FF5533.
  • Eight digits adds an alpha channel: #FF5733CC.
  • Hex is case-insensitive - #ff5733 and #FF5733 are identical.
  • HSL is derived from the same RGB values and is often easier to adjust.

Converting by hand

HEX to RGB

  1. Split the six digits into three pairs.
  2. Convert each pair from hexadecimal to decimal.
  3. For a pair, multiply the first digit by 16 and add the second.

For FF: F is 15, so 15 × 16 + 15 = 255. For 57: 5 × 16 + 7 = 87. For 33: 3 × 16 + 3 = 51.

RGB to HEX

  1. Divide each value by 16; the quotient is the first digit and the remainder the second.
  2. Convert values 10-15 to the letters A-F.
  3. Pad single digits with a leading zero.
Hex digitDecimalHex digitDecimal
0-9SameC12
A10D13
B11E14
F15

Shorthand and alpha

FormExampleMeans
6 digits#FF5733Standard RGB
3 digits#F53Shorthand - each digit doubled, so #FF5533
8 digits#FF5733CCRGB plus alpha, CC being 80% opaque
4 digits#F53CShorthand with alpha

Three-digit shorthand can only express 4,096 colors rather than 16.7 million, since each channel is limited to 16 values. It is a convenience for round numbers like #FFF or #333, not a general shortcut.

Common color values

ColorHEXRGBHSL
White#FFFFFFrgb(255, 255, 255)hsl(0, 0%, 100%)
Black#000000rgb(0, 0, 0)hsl(0, 0%, 0%)
Red#FF0000rgb(255, 0, 0)hsl(0, 100%, 50%)
Green#00FF00rgb(0, 255, 0)hsl(120, 100%, 50%)
Blue#0000FFrgb(0, 0, 255)hsl(240, 100%, 50%)
Yellow#FFFF00rgb(255, 255, 0)hsl(60, 100%, 50%)
Cyan#00FFFFrgb(0, 255, 255)hsl(180, 100%, 50%)
Magenta#FF00FFrgb(255, 0, 255)hsl(300, 100%, 50%)
Mid gray#808080rgb(128, 128, 128)hsl(0, 0%, 50%)

A color is a shade of gray precisely when all three channels are equal, which is why every gray has 0% saturation in HSL.

Why 16.7 million colors

Each channel has 256 possible values, so the total is 256³ = 16,777,216. This is "24-bit true color", eight bits per channel, and it comfortably exceeds the number of distinct colors the human eye can discriminate in most viewing conditions.

Modern displays increasingly support wider gamuts and deeper bit depths - 10 bits per channel gives over a billion values - which is why CSS added color functions such as color(display-p3 ...) that can address colors outside the traditional sRGB range.

Alpha and opacity

OpacityHex alphaDecimal
100%FF1.0
75%BF0.75
50%800.5
25%400.25
10%1A0.1
0%000.0
Alpha is not the same as the opacity property. An alpha channel on a color affects only that color - a semi-transparent background with fully opaque text on top. The CSS opacity property applies to the whole element including its contents, so the text fades too. The distinction matters more often than people expect.
Everything runs in your browser. Your code and files are processed entirely on your own device - nothing is uploaded, logged or stored.

Frequently Asked Questions

How do I convert HEX to RGB?

Split the six digits into three pairs and convert each from hexadecimal to decimal. For a pair, multiply the first digit by 16 and add the second, treating A to F as 10 to 15. So FF becomes 255 and 57 becomes 87.

What does a HEX color code represent?

The red, green and blue channel values written in hexadecimal. #FF5733 means red 255, green 87, blue 51. Two hex digits express the full 0 to 255 range in a fixed width, which is why the format is exactly six characters.

What is three-digit HEX shorthand?

A shortened form where each digit is doubled, so #F53 means #FF5533. It can only express 4,096 colors rather than 16.7 million, so it is a convenience for round values like #FFF or #333 rather than a general shortcut.

What does an 8-digit HEX code mean?

The first six digits are the RGB color and the last two are the alpha channel controlling opacity. FF is fully opaque, 80 is about 50 percent, and 00 is fully transparent.

Is HEX case-sensitive?

No. #FF5733 and #ff5733 are identical. Uppercase is the more common convention in design tools, lowercase in many codebases. Pick one and be consistent within a project.

Why are there 16.7 million colors?

Because each of the three channels has 256 possible values, and 256 cubed is 16,777,216. This is 24-bit true color, which exceeds what the human eye can distinguish in most viewing conditions.

How do I know if a color is gray?

All three channels are equal - #808080, #333333, #CCCCCC. In HSL this shows as 0 percent saturation, since there is no color information at all, only lightness.

What is the difference between alpha and the CSS opacity property?

An alpha channel affects only the color it belongs to, so a semi-transparent background can carry fully opaque text. The opacity property applies to the entire element including its contents, fading the text as well.

Related Calculators