RGB to hex converter

Enter red, green and blue values from 0 to 255.

How RGB to hex works

Each channel is divided by 16: the whole number is the first hex digit and the remainder is the second. Digits 10 to 15 are written A to F.

Common colors in RGB and hex

ColorRGBHEX
Red255, 0, 0#FF0000
Green0, 128, 0#008000
Blue0, 0, 255#0000FF
Black0, 0, 0#000000
White255, 255, 255#FFFFFF
Gray128, 128, 128#808080
Navy Blue0, 0, 128#000080
Teal0, 128, 128#008080
Sage Green156, 175, 136#9CAF88
Burgundy128, 0, 32#800020
Lavender230, 230, 250#E6E6FA
Gold255, 215, 0#FFD700
Coral255, 127, 80#FF7F50
Hot Pink255, 105, 180#FF69B4
Beige245, 245, 220#F5F5DC
Charcoal54, 69, 79#36454F

Questions

How do you convert RGB to hex?
Convert each of the red, green and blue values (0 to 255) to a two-digit base 16 number and join them. RGB 156, 175, 136 becomes 9C, AF, 88, so the hex code is #9CAF88.
Why does my hex code need leading zeros?
Every channel needs two digits. A value of 8 is 08 in hex, so RGB 8, 8, 8 is #080808, not #888.

More color tools