RGB to Hex Converter

Enter red, green and blue values from 0 to 255 to get the hex code. Click any result to copy it.

How to convert RGB to hex

Each RGB value is a number from 0 to 255. Divide it by 16: the whole-number result is the first hex digit and the remainder is the second. Write 10 to 15 as A to F, then join the three pairs after a #.

rgb(172, 247, 66)
172 ÷ 16 = 10 remainder 12, so A and C = AC
247 ÷ 16 = 15 remainder 7, so F and 7 = F7
66 ÷ 16 = 4 remainder 2, so 4 and 2 = 42
Result: #ACF742

Values below 16 need a leading zero, so 5 becomes 05 and rgb(5, 5, 5) becomes #050505.

RGBA to hex

For transparency, multiply the alpha (0 to 1) by 255, round it, and add it as a fourth pair. rgba(172, 247, 66, 0.5) gives 0.5 × 255 = 127.5, which rounds to 128, or 80 in hex: #ACF74280. Type the alpha in the converter’s Alpha box and it adds that pair for you.

Tip: you can paste a whole value like rgb(172, 247, 66) into any of the three boxes and the converter fills all of them.

Common RGB colors in hex

Select a color name for its full page, or use Load to try it in the converter.

ColorHexRGBLoad into the converter
Black#000000rgb(0, 0, 0)
White#FFFFFFrgb(255, 255, 255)
Red#FF0000rgb(255, 0, 0)
Lime#00FF00rgb(0, 255, 0)
Blue#0000FFrgb(0, 0, 255)
Yellow#FFFF00rgb(255, 255, 0)
Cyan#00FFFFrgb(0, 255, 255)
Magenta#FF00FFrgb(255, 0, 255)
Silver#C0C0C0rgb(192, 192, 192)
Gray#808080rgb(128, 128, 128)
Maroon#800000rgb(128, 0, 0)
Olive#808000rgb(128, 128, 0)
Green#008000rgb(0, 128, 0)
Purple#800080rgb(128, 0, 128)
Teal#008080rgb(0, 128, 128)
Navy#000080rgb(0, 0, 128)
Orange#FFA500rgb(255, 165, 0)
Pink#FFC0CBrgb(255, 192, 203)
Brown#A52A2Argb(165, 42, 42)
Gold#FFD700rgb(255, 215, 0)

RGB to hex questions

What is rgb(0, 0, 0) in hex?

#000000, which is black. rgb(255, 255, 255) is #FFFFFF.

When can a hex code be shortened?

When each pair is a repeated digit. #FFAA33 can be written #FA3, but #ACF742 cannot.

Why does my color look different when printed?

Screens mix light (RGB) and printers mix ink (CMYK), and some bright screen colors have no exact ink match. Check the print version with the RGB to CMYK converter. To go back from a hex code, use the hex to RGB converter.