How to convert RGB to Hex









How to convert RGB to Hex

The RGB color code is a combination of Red, Green and Blue colors. (R, G, B). The red, green and blue colors have integer values from 0 to 255 and each of them uses 8 bits. Therefore, the number of colors that can be generated is;

256×256×256 = 16777216

= 100000016

The Hex color code is a 6 digits hexadecimal number of base 16. This can be expressed as; RRGGBB16.

Where;

The left 2 digits represent the red color (RR), the 2 middle digits represent the green color (GG) and the 2 right digits represent the blue color (BB).









Formula for converting RGB to hex

The first step is to convert the red, green and blue color codes from decimal to Hex code. The 3 hex values are then concentrated together; RRGGBB

Example one

Convert gold color (255, 215, 0) to hex color code:

R = 25510 = FF16

G = 21510 = D716

B = 010 = 0016

Therefore, the hex color code will be:

Hex = FFD700

Example two

Convert red color (255, 0, 0) to hex color code:

R = 25510 = FF16

G = 010 = 0016

B = 010 = 0016

Therefore, the hex color code is:

Hex = FF0000

The RGB to Hex conversion calculator gives quick results based on the input values. The red, green and blue color codes range from 0 to 255. When using the calculator, you only have to enter the RGB values in their respective fields and then click the ‘Convert’ button. This gives you the result in Hex color code. Its efficiency is enhanced by the ‘Reset’ button which erases all previous data from the calculator. The RGB to Hex conversion tables highlights some of the common color code conversions from RGB to Hex.