How to convert hex to RGB color

How to convert from hexadecimal color code to RGB color.

Hex color code

Hex color code is a 6 digits hexadecimal (base 16) number:

RRGGBB16

The 2 left digits represent the red color.

The 2 middle digits represent the green color.

The 2 right digits represent the blue color.

RGB color

The RGB color is a combination of Red, Green and Blue colors:

(R, G, B)

The red, green and blue use 8 bits each, which have integer values from 0 to 255.

So the number of colors that can be generated is:

256×256×256 = 16777216 = 100000016

Hex to RGB conversion

  1. Get the 2 left digits of the hex color code and convert to decimal value to get the red color level.
  2. Get the 2 middle digits of the hex color code and convert to decimal value to get the green color level.
  3. Get the 2 right digits of the hex color code and convert to decimal value to get the blue color level.

Example #1

Convert red hex color code FF0000 to RGB color:

Hex = FF0000

So the RGB colors are:

R = FF16 = 25510

G = 0016 = 010

B = 0016 = 010

Or

RGB = (255, 0, 0)

Example #2

Convert gold hex color code FFD700 to RGB color:

Hex = FFD700

So the RGB colors are:

R = FF16 = 25510

G = D716 = 21510

B = 0016 = 010

Or

RGB = (255, 215, 0)

 

How to convert RGB to hex ►

 


See also

COLOR CONVERSION
CONTACT