Convert Hex Color to RGB
Convert a hexadecimal color code to RGB values, with a real-time preview.
Your data is never sent to any server.
The hex to RGB converter turns a color code such as #FF8800 into its
rgb(255, 136, 0) form. It accepts the 6-digit code and its 3-digit shorthand,
and gives you the function ready to paste into your CSS plus the three channels
one by one.
How to read a hex code
A hex color is three two-digit numbers in base 16, one per channel:
| Red | Green | Blue | |
|---|---|---|---|
| Hex | FF | 88 | 00 |
| Decimal | 255 | 136 | 0 |
Each pair goes from 00 to FF, that is, from 0 to 255. The digits A to F are
worth 10 to 15, so 88 is 8 × 16 + 8 = 136.
When you need the numbers
In CSS, hex and rgb() are interchangeable, so converting only matters when the
next step works with channels. That happens when you read or edit pixels on a
canvas with getImageData, in charting libraries that want each channel as a
number, or when you compute a gradient or a blend between two colors, which is
done channel by channel. If what you want is to add transparency to a palette
color, the hex to RGBA converter gives you the rgba() with
the opacity you choose.
How to use Hex to RGB
- 1
Type the hex code
Enter the color with or without the # sign. The long 6-digit form (#FF8800) and the short 3-digit form (#F80) both work. The field ignores anything that is not a hex digit.
- 2
Check it is complete
The conversion runs as soon as the code has 3 or 6 digits. The hint next to the field turns green to confirm it.
- 3
Copy the rgb()
The result shows the CSS-ready rgb() function, a swatch of the color and the three channels one by one.
Frequently asked questions
How many digits does the hex code need?
3 or 6, not counting the #. In the long form each pair of digits is one channel. The short form doubles each digit, so #F80 is the same as #FF8800. Any other length is incomplete and is not converted.
What if my hex has 8 digits?
The last two are the transparency channel, and rgb() has nowhere to store it. For those codes use the hex to RGBA converter, which keeps the opacity.
Does upper or lowercase matter?
No. #ff8800 and #FF8800 are the same color. The field switches to uppercase only to make it easier to read.
How do I convert it by hand?
Each pair of digits is a base 16 number: the first digit is worth 16 times its value and the second is worth its value. So 88 is 8 × 16 + 8 = 136, and FF is 15 × 16 + 15 = 255.
What do the R, G and B values mean?
The intensity of red, green and blue, each from 0 to 255. rgb(0, 0, 0) is black, rgb(255, 255, 255) is white, and three equal values always give a gray.