Skip to content
OverCalculator
  1. Home
  2. Conversion
  3. HEX to RGB Converter
Conversion

HEX to RGB Converter

Convert HEX color codes into RGB channels, expand #RGB shorthand, and understand how CSS hex pairs map to red, green, and blue values.

Published

Color value
RGB color
rgb(51, 102, 204)
Red
51
Green
102
Blue
204
HEX
#3366CC

#3366CC uses red 51, green 102, and blue 204 on the 0-255 RGB scale.

Conversion direction
Enter three or six hexadecimal digits, with or without the # sign.

Results update as you type.

HEX to RGB Converter

The HEX to RGB converter reads a CSS-style hex color such as #3366CC and splits it into the red, green, and blue channel values that design tools, canvas code, image scripts, and color documentation often display. Select RGB β†’ HEX in the same form to encode three decimal channel values. Each RGB channel must be a whole number from 0 through 255; fractional channels are rejected rather than rounded.

Hex notation is compact because it writes each 0-to-255 channel as two hexadecimal digits. That is convenient in stylesheets and design tokens, but it hides the channel balance. Converting to RGB makes the color easier to inspect: you can see whether a blue is strong because the blue channel is high, whether a gray is neutral because all channels match, or whether a brand color is warmer because red exceeds blue.

How CSS hex color encoding works

Hexadecimal is base 16. It uses digits 0 through 9 and letters A through F, where A means 10, B means 11, and F means 15. A two-digit hex pair can represent 256 values:

16β‹…16=25616 \cdot 16 = 256

That exactly matches the 0 through 255 range of an 8-bit color channel. A six-digit color has the pattern #RRGGBB: first red, then green, then blue. For #3366CC, the pairs are:

red=3316,green=6616,blue=CC16\text{red} = 33_{16},\quad \text{green} = 66_{16},\quad \text{blue} = CC_{16}

Each pair is converted independently. The converter also accepts three-digit shorthand such as #36C. In CSS shorthand, each digit is doubled, so #36C becomes #3366CC before the channel values are calculated.

For a general base-16 number tool, see the decimal to hexadecimal converter. For binary and byte concepts behind digital values, the binary calculator and digital storage converter are useful companions.

Formula

For a hex pair with first digit a and second digit b, where each digit has a decimal value from 0 to 15:

channel10=16β‹…a+b\text{channel}_{10} = 16 \cdot a + b

The full color is read as:

#RRGGBB→rgb(red, green, blue)\#RRGGBB \rightarrow \text{rgb}(\text{red},\ \text{green},\ \text{blue})

For #3366CC, 3 has decimal value 3, 6 has decimal value 6, and C has decimal value 12:

3316=16β‹…3+3=5133_{16} = 16 \cdot 3 + 3 = 51

6616=16β‹…6+6=10266_{16} = 16 \cdot 6 + 6 = 102

CC16=16β‹…12+12=204CC_{16} = 16 \cdot 12 + 12 = 204

So the RGB form is rgb(51, 102, 204).

Conversion example using the stated method

Leave the conversion direction set to HEX to RGB and enter the default #3366CC. The calculator trims the leading hash, validates that the remaining value has either three or six hex digits, and normalizes the value to uppercase. The six digits split into 33, 66, and CC.

The decimal conversions are 51, 102, and 204, so the primary result is rgb(51, 102, 204). The result details list Red: 51, Green: 102, Blue: 204, and HEX: #3366CC. The note states that #3366CC uses red 51, green 102, and blue 204 on the 0-255 RGB scale, and the copy text is #3366CC = rgb(51, 102, 204).

If you enter shorthand #36C, the converter expands it to #3366CC and returns the same RGB channels. If you enter a value with non-hex characters, such as #33GGCC, the calculator marks it invalid because G is not a hexadecimal digit.

For the reverse direction, select RGB β†’ HEX and enter whole-number red, green, and blue channels from 0 through 255. The form converts each channel to one two-digit hexadecimal pair without changing or rounding the channel value.

Reference table for reading hex colors

HEX colorCommon nameRedGreenBlueRGB notation
#000000Black000rgb(0, 0, 0)
#FFFFFFWhite255255255rgb(255, 255, 255)
#FF0000Red25500rgb(255, 0, 0)
#00FF00Lime02550rgb(0, 255, 0)
#0000FFBlue00255rgb(0, 0, 255)
#808080Gray128128128rgb(128, 128, 128)
#FA8072Salmon250128114rgb(250, 128, 114)
#663399RebeccaPurple10251153rgb(102, 51, 153)

Named colors are included here only as recognizable examples. The converter itself does not look up color names; it decodes numeric hex values.

Interpreting the RGB channels

RGB values describe additive light. Higher channel numbers mean more light from that channel. Equal channel values create grays because red, green, and blue are balanced. When blue is much higher than red and green, the color appears blue or cool. When red and green are high but blue is low, the color moves toward yellow.

This channel view helps when debugging CSS. A color that looks too purple may have too much blue relative to green. A muted color often has channels closer together than a saturated one. Converting from hex to RGB lets you reason about these relationships without mentally decoding base 16.

It also makes handoff conversations clearer. A designer can say that the blue channel is the dominant value, a developer can compare the same numbers in a browser inspector, and a content editor can document the approved RGB notation without changing the original brand color.

Common mistakes

  • Reading #RRGGBB in the wrong order. CSS hex uses red, then green, then blue.
  • Treating CC as decimal cc; it is base 16 and equals 204.
  • Forgetting that #36C expands to #3366CC, not #3060C0.
  • Including opacity digits such as #RRGGBBAA; this converter expects three or six hex digits.
  • Entering RGB percentages in the reverse mode when the calculator expects 0-to-255 channel values.
  • Entering fractional RGB channels; reverse mode accepts only whole-number byte values.
  • Assuming a color name is accepted; use the actual hex code instead.

Sources

Frequently asked questions

What does a HEX color code represent?
A six digit HEX color stores red, green, and blue as three base 16 byte values. In #3366CC, 33 is the red channel, 66 is the green channel, and CC is the blue channel used to render the color on screen.
Can I include the hash sign?
Yes. The converter accepts a leading hash sign or a bare value. It trims the hash before reading the digits, then displays the normalized result with a hash so the code is ready for CSS declarations, design notes, and browser inspectors.
How does three digit shorthand work?
Three digit shorthand repeats each digit to form a six digit value. For example, #36C expands to #3366CC. It is only an exact shorthand when each channel has two identical hex digits in the full color notation used by CSS.

Related calculators

HEX to RGB Converter updated at