Hex to RGB Calculator

Web and design tools store colors as six-digit hex codes, but image editors and many programming interfaces expect three numbers from 0 to 255. This calculator bridges the two by converting a hex color code into its red, green and blue components. A hex code is simply three pairs of hexadecimal digits laid end to end: the first pair is the red channel, the second is green and the third is blue. Each pair is one byte, ranging from 00 to FF, which in everyday decimal is 0 to 255. Converting is just reading each pair as a base-16 number: 33 becomes 51, 66 becomes 102 and CC becomes 204. Enter a code such as 3366CC, with or without the leading hash, and the page returns the three channel values and a CSS rgb() string you can paste straight into a stylesheet. Three-digit shorthand like 36C expands by doubling each digit, so enter the full six-digit form. This conversion is the everyday bridge between design files and code. Every value is computed deterministically by splitting the bytes and converting them, never estimated or looked up, so the result updates instantly, with the method and a worked example shown below for verification.

Each hex pair is one channel, converted from base 16 to a value 0 to 255: RGB = (hex[0:2], hex[2:4], hex[4:6]). The code 3366CC converts to rgb(51, 102, 204).

Source: US National Institute of Standards and Technology (NIST). As at 25 June 2026.

Six hex digits, hash optional
Red--
Green--
Blue--
CSS value--

Hex to RGB formula

R = hex digits 1 and 2, converted from base 16
G = hex digits 3 and 4, converted from base 16
B = hex digits 5 and 6, converted from base 16
each pair ranges from 00 (0) to FF (255)

A pair of hex digits is one byte. The left digit is the sixteens place and the right digit is the ones place, so a pair equals left times 16 plus right, giving a value from 0 to 255.

Worked example

Convert the hex code 3366CC into red, green and blue.

  1. Red = 33 in hex = 3 x 16 + 3 = 51
  2. Green = 66 in hex = 6 x 16 + 6 = 102
  3. Blue = CC in hex = 12 x 16 + 12 = 204
  4. CSS value = rgb(51, 102, 204)

The code 3366CC is rgb(51, 102, 204). This is the calculator's default input, so the result above matches the widget exactly.

Common hex digit values

The right column is the decimal value of a digit in the sixteens or ones place.

Hex digitDecimal
0 to 90 to 9
A10
B11
C12
D13
E14
F15

Number bases and digital representation: US National Institute of Standards and Technology (NIST).

Hex to RGB calculator: frequently asked questions

How do you convert hex to RGB?

A six-digit hex color code is three pairs of hexadecimal digits, one each for red, green and blue. Convert each two-digit pair from base 16 to base 10 to get a value from 0 to 255. For example 33 in hex equals 51 in decimal.

What do the hex digits mean?

Each hex digit represents 4 bits, so a pair of digits represents 8 bits, or one byte, which ranges from 00 to FF. FF in hex is 255 in decimal, the maximum intensity of a channel. The first pair is red, the second green and the third blue.

Can I use a three-digit shorthand?

Yes. A three-digit code such as #36C is shorthand where each digit is doubled, so #36C expands to #3366CC. This calculator works with the full six-digit form; expand shorthand first by repeating each digit.

Is the leading hash required?

The hash is just a prefix that marks the value as a hex color in CSS and design tools. The conversion uses only the six digits. You can enter the code with or without the hash and the result is the same.

Is the result computed automatically?

Yes. The page splits the code into byte pairs and converts each from base 16 deterministically. No value is estimated or hard-coded, so changing the code updates the red, green and blue outputs instantly.

Official sources

Reviewed by the CalculatorHub team, edited by James Graham, 25 June 2026. See our methodology. This is general information, not financial, tax, legal or investment advice.