RGB / Hex Conversion Calculator

This easy-to-use color converter tool can convert RGB color values into hexadecimal codes, and vice versa.

RGB <-> Hex Converter

Reference

With CSS and HTML, color codes are either the trio of RGB values or hexadecimal numbers, e.g., if you wanted to turn your text green, you can either use the CSS command color:rgb(0, 128, 0) or the command color:#008000.

For the RGB code, the numbers in brackets are the quantities of red, green, and blue, in that order. All the numbers can have a value from 0 (lowest amount) to 255 (highest amount). Red, green and blue are light's three primary colors, and by adjusting the amount of each you can create 2563 colors, that's 16,777,216 colors in all. To avoid confusion, the primary colors of light are different to the primary colors of pigments that you may be more familiar with, these are red, yellow and blue.

When colors are represented by hexadecimal numbers, every color is assigned a six digit base 16 number. Base-16 number systems employ digits 0 – 9 and letters A – F (in either upper or lowercase). The first two numbers in the array tell you how much red there is, the middle two how much green, and the last two how much blue.

With hexadecimal codes, the lowest possible to digit number is 00 with the highest being FF/ff, equal to 255 in base 10. This gives the same number of potential shades for each of the base colors as with the RGB system, again offering 16,777,216 colors.

Converting RGB to Hex

For conversion of a triple RGB value to a single hex value, all the base-10 numbers must be converted into base-16 numbers and the derived values joined together to produce a hex value.

An example would be the RGB color yellow green, for which the CSS code is color:rgb(154, 205, 50). In hex values, 154 is 9A, 205 is CD, and 50 is 32, making our CSS hex code color:#9ACD32 or color:#9acd32

Converting Hex to RGB

For conversion of the 6-digit hex code into an RGB code, firstly we divide the hexadecimal code into 32 character sections. Each base-16 number is then converted to the base-10 equivalent.

An example would be the color brown, for which the hexadecimal code is color:#A52A2A or color:#a52a2a. Converted into base 10, A5 = 165 and 2A = 42, so the translated RGB code becomes color:rgb(165, 42, 42).

Basic Named Colors
SampleColor NameHex CodeRGB Code
Black #000000 (0,0,0)
White #FFFFFF (255,255,255)
Silver #C0C0C0 (192,192,192)
Gray #808080 (128,128,128)
Red #FF0000 (255,0,0)
Maroon #800000 (128,0,0)
Orange #FFA500 (255,165,0)
Yellow #FFFF00 (255,255,0)
Olive #808000 (128,128,0)
Lime #00FF00 (0,255,0)
Green #008000 (0,128,0)
Teal #008080 (0,128,128)
Aqua #00FFFF (0,255,255)
Blue #0000FF (0,0,255)
Navy #000080 (0,0,128)
Purple #800080 (128,0,128)
Fuchsia #FF00FF (255,0,255)

You may also be interested in our free RGB to Grayscale Conversion Calculator

Rating: 4.2/5 (45 votes)