Skip to content

RGB to hex

Enter a red, green and blue value from 0 to 255 and get the hex code, along with every other way the same color can be written. Everything is worked out in your browser, so nothing is sent anywhere.

Convert RGB to hex

Click any code to copy it.

#0F52BA
Every code for the color you entered. Click a value to copy it.
HEX
RGB
HSL
HSV / HSB
CMYK
HWB
LAB
LCH
LUV
XYZ

Common questions

How do you convert RGB to hex?
Each channel is a number from 0 to 255, and each becomes two hexadecimal digits. Divide the value by 16 for the first digit and take the remainder for the second, using A to F for 10 to 15. So 82 is 5 remainder 2, which is 52. Join the three pairs in red, green, blue order and put a hash in front.
What is rgb(15, 82, 186) in hex?
It is #0F52BA. 15 is 0F, 82 is 52 and 186 is BA. That colour is commonly called sapphire.
Why does hex use letters?
Because it counts in sixteens rather than tens, and there are no single digits for the values 10 to 15, so A to F stand in. Sixteen matters here because one byte holds exactly 256 values, which is exactly two hex digits. That is why a colour channel fits so neatly into a pair.
Do I need the hash in front of a hex code?
In CSS and HTML, yes. The hash is what tells the parser the characters after it are a hex colour rather than anything else. In design tools it is usually optional, and most will accept the six characters on their own.
Can every RGB colour be written as hex?
Every whole-number RGB colour, yes, because both describe the same 16,777,216 combinations. What hex cannot carry is an alpha channel in the classic six-digit form, or the fractional and wide-gamut values that rgb() now accepts in modern CSS.
All tools
Share