Paste a HEX code to get RGB, or type RGB values to get HEX. Both sides update as you type.
3, 6 or 8 digits, with or without #
It converts color codes in both directions. Paste a HEX code to get its rgb(), rgba() and hsl() values, or type red, green and blue numbers to get the HEX code. It reads 3, 6 and 8 digit HEX codes, with or without the #, and updates as you type.
#ff922e or ff922e into the HEX field.To convert RGB to HEX, type values from 0 to 255 into R, G and B, then copy the HEX row. Set Alpha below 1 to get an 8-digit HEX code with transparency.
A six-digit HEX code is three pairs of base 16 digits: red, green, then blue. Each digit runs from 0 to 9 and then A to F, which stand for 10 to 15. To turn a pair into a number from 0 to 255, multiply the first digit by 16 and add the second.
FF = 15 × 16 + 15 = 255 red
92 = 9 × 16 + 2 = 146 green
2E = 2 × 16 + 14 = 46 blue
#FF922E = rgb(255, 146, 46)
RGB to HEX runs the same math backward. Divide each value by 16: the whole number is the first digit and the remainder is the second, so 146 ÷ 16 is 9 remainder 2, which gives 92.
| Color | HEX | RGB |
|---|---|---|
| Red | #FF0000 | rgb(255, 0, 0) |
| Orange | #FFA500 | rgb(255, 165, 0) |
| Yellow | #FFFF00 | rgb(255, 255, 0) |
| Green | #008000 | rgb(0, 128, 0) |
| Teal | #008080 | rgb(0, 128, 128) |
| Blue | #0000FF | rgb(0, 0, 255) |
| Navy blue | #000080 | rgb(0, 0, 128) |
| Purple | #800080 | rgb(128, 0, 128) |
| Pink | #FFC0CB | rgb(255, 192, 203) |
| White | #FFFFFF | rgb(255, 255, 255) |
| Gray | #808080 | rgb(128, 128, 128) |
| Black | #000000 | rgb(0, 0, 0) |
Need a color first? Find one with the color picker. Then check text on it with the contrast checker, get lighter and darker versions from the tint and shade generator, or blend two codes in the color mixer. The color wheel and palette generator build a full set around one color.
Split the six digits into three pairs for red, green and blue. Convert each pair from base 16 by multiplying the first digit by 16 and adding the second, where A to F stand for 10 to 15. #FF922E becomes 255, 146 and 46, written as rgb(255, 146, 46).
Divide each of the three values by 16. The whole number is the first HEX digit and the remainder is the second, with 10 to 15 written as A to F. Join the three pairs after a #. For example, rgb(59, 130, 246) gives 3B, 82 and F6, so the code is #3B82F6.
The last two digits set the opacity, also called alpha. 00 is fully transparent and FF is fully opaque, so #FF922E80 is the same orange at about 50% opacity. To get the alpha for rgba(), divide the pair's decimal value by 255. 80 is 128, and 128 ÷ 255 rounds to 0.5.
Yes, it is shorthand. Browsers double each digit, so #F80 means #FF8800 and #FFF means #FFFFFF. Only colors whose pairs repeat a digit have a short form, which limits three-digit codes to 4,096 colors, while six digits can express about 16.7 million.
Either one works, and browsers render them identically. HEX is shorter and easy to paste from design tools. rgb() is easier to read and to tweak one channel at a time. For transparency, use an 8-digit HEX code or rgb() with an alpha value. Current browsers support both.