Skip to content
tools.best

Browse all tools

Hex to RGB Converter

Type a hex color code to get its red, green and blue values: #FF6600 is rgb(255, 102, 0).

Runs in your browser. Nothing you enter is sent to a server. Sources: W3C CSS Color 4 Updated

3, 4, 6 or 8 hex digits, with or without #. The result updates as you type.

RGB

rgb(255, 102, 0)

Red 255, green 102, blue 0. Full code #FF6600.

RGB to hex

Whole numbers from 0 to 255.

Hex

#FF6600

rgb(255, 102, 0)

How hex to RGB conversion works

A hex color code is three numbers written in base 16. In a 6-digit code the first pair of digits is red, the second is green and the third is blue. Each pair runs from 00 to FF, which is 0 to 255 in ordinary decimal numbers.

value = first digit × 16 + second digit   (A = 10, B = 11, C = 12, D = 13, E = 14, F = 15)

Base 16 is the same notation the text to hex converter uses for bytes: one pair of digits is one byte, 0 to 255. The tool accepts four lengths, as defined for CSS colors:

DigitsPatternExampleResult
6#RRGGBB#FF6600rgb(255, 102, 0)
3#RGB, each digit doubled#F60rgb(255, 102, 0)
8#RRGGBBAA, last pair is alpha#FF660080rgba(255, 102, 0, 0.5)
4#RGBA, each digit doubled#F608rgba(255, 102, 0, 0.533)

Anything else is not a hex color: a code with 5 or 7 digits, or one with letters after F, gives no result.

Hex to RGB example: #FF6600

Convert #FF6600.

  • Red: FF = 15 × 16 + 15 = 255
  • Green: 66 = 6 × 16 + 6 = 102
  • Blue: 00 = 0 × 16 + 0 = 0

The result is rgb(255, 102, 0), a strong orange.

To go the other way, divide each value by 16. The whole part is the first digit and the remainder is the second. 102 ÷ 16 is 6 remainder 6, so green is 66.

For print, a screen color is often matched to a Pantone ink. The hex to Pantone converter and the RGB to Pantone converter suggest the nearest entries from an unofficial table and show how far off each one is.

#FF6600 split into its channels by the hex to RGB converter: FF = 15 × 16 + 15 = 255 red, 66 = 6 × 16 + 6 = 102 green and 00 = 0 blue, so the color is rgb(255, 102, 0), an orange.
Each pair of hex digits is one channel; the bars show each value out of 255.

Alpha in 4- and 8-digit codes

The alpha pair sets how opaque the color is: 00 is fully transparent and FF is fully opaque. In rgba() alpha is written as a number from 0 to 1, so the tool divides the pair by 255. 80 is 128, and 128 ÷ 255 = 0.502, shown as 0.5. Alpha is rounded to two decimals when that still converts back to the same pair, and to three decimals when it does not.

Common CSS colors in hex and RGB

These are color names defined in CSS, with their hex codes and RGB values.

NameHexRGB
black#000000rgb(0, 0, 0)
white#FFFFFFrgb(255, 255, 255)
gray#808080rgb(128, 128, 128)
silver#C0C0C0rgb(192, 192, 192)
red#FF0000rgb(255, 0, 0)
maroon#800000rgb(128, 0, 0)
orange#FFA500rgb(255, 165, 0)
yellow#FFFF00rgb(255, 255, 0)
lime#00FF00rgb(0, 255, 0)
green#008000rgb(0, 128, 0)
aqua#00FFFFrgb(0, 255, 255)
teal#008080rgb(0, 128, 128)
blue#0000FFrgb(0, 0, 255)
navy#000080rgb(0, 0, 128)
fuchsia#FF00FFrgb(255, 0, 255)
purple#800080rgb(128, 0, 128)

Hex to RGB Converter: FAQ

How do I convert hex to RGB by hand?
Split the six digits into three pairs: red, green, blue. For each pair, multiply the first digit by 16 and add the second, counting A as 10 up to F as 15. For #FF6600: FF is 15 × 16 + 15 = 255, 66 is 6 × 16 + 6 = 102 and 00 is 0, so the color is rgb(255, 102, 0).
What does a 3-digit hex code mean?
It is a short form of a 6-digit code. Each digit is written twice, so #F60 is the same color as #FF6600. Only colors whose pairs are doubled digits can be shortened this way.
What are 4-digit and 8-digit hex codes?
They add an alpha value, which sets how opaque the color is. In #FF660080 the last pair, 80, is the alpha: 00 is fully transparent and FF is fully opaque. A 4-digit code such as #F608 is the short form, with each digit doubled to give #FF660088.
Does it matter whether the letters are upper or lower case?
No. #ff6600 and #FF6600 are the same color. The # at the start is also optional in this tool, although CSS needs it.
Why does 80 as an alpha value show as 0.5?
Hex 80 is 128, and 128 ÷ 255 is 0.502. The tool rounds alpha to two decimals when that still converts back to the same hex pair, and uses three decimals when it does not. The exact value is shown under the result.

Sources