Convert color HEX to RGB

HEX and RGB are two ways of writing the same color: HEX uses a six-digit code like #3366ff, while RGB expresses it as three numbers (red, green, blue) from 0 to 255. Converting between them is handy when a design tool, CSS file, or image editor only accepts one format.

Enter HEX color value or move sliders to change color value

Result
Type: Semi dark
RGB: rgb(4, 65, 153)
HSL: hsl(215, 95%, 31%)
Palettes:
Shades:
Tints:

How to convert HEX to RGB

A HEX code is three pairs of hexadecimal digits: the first pair is red, the second green and the third blue. Each pair runs from 00 to FF, which is 0 to 255 in decimal.

To convert a pair, multiply the first digit by 16 and add the second, counting A as 10 through F as 15. For #3366FF that gives 33 = 3 × 16 + 3 = 51, 66 = 6 × 16 + 6 = 102 and FF = 15 × 16 + 15 = 255, so the color is rgb(51, 102, 255).

Short and 8-digit HEX codes

A three-digit code is shorthand in which each digit is doubled, so #36F is the same as #3366FF. An eight-digit code such as #3366FF80 adds a fourth pair for transparency: 80 is 128 in decimal, or about 50% opacity, which CSS writes as rgba(51, 102, 255, 0.5).

When to use HEX or RGB

HEX is compact, and it's the format most design tools and brand guides use. RGB is easier to read and tweak by hand, and you need it when a script changes one channel at a time or when you add transparency with rgba().

Convert color RGB to HEX