Pantone Colors

HEX to RGB Converter

A HEX to RGB converter turns a six-digit hexadecimal color code into a red, green, and blue triplet. For example, #FF0000 becomes rgb(255, 0, 0) ” pure red. The conversion is exact: every HEX value has one RGB equivalent, and every RGB triplet has one HEX code. No interpolation, no gamut mapping, no loss.

What is HEX to RGB conversion?

HEX (hexadecimal) is a base-16 notation for colors that browsers understand natively. It is written as a hash symbol followed by six characters ” 0“9 or A“F ” split into three pairs. The first pair encodes red, the second green, the third blue. Each pair is a hexadecimal number from 00 to FF, or 0 to 255 in decimal.

RGB (red, green, blue) expresses the same color as three decimal integers between 0 and 255. It is the color model that displays, image formats, and canvas APIs actually use internally. Browsers convert HEX to RGB the moment they paint a pixel ” the HEX string is human convenience, not machine necessity.

The two notations describe identical colors. HEX is shorter and more compact, which is why designers write it in CSS, design tools, and brand guidelines. RGB is more explicit and easier to compute with, which is why it appears in JavaScript, WebGL, and image processing. Converting between them is a straight base-16 to base-10 translation ” no color space change.

How to use this converter

  1. Type or paste a HEX code in the input field, with or without the leading #.
  2. Or click the color picker to choose visually ” the HEX field updates automatically.
  3. Read the RGB result below: three integers, one each for red, green, and blue.
  4. Click Copy to grab the CSS-ready rgb() string or individual channel values.

How the conversion works technically

A HEX color is a 24-bit integer. Parsing #RRGGBB means reading the hex digits as a base-16 number. The first two digits form red, the middle two green, the last two blue. Each hex digit is worth 0“15 in decimal, where A=10, B=11, C=12, D=13, E=14, F=15.

Take #FF5000. FF (red) = 15—16 + 15 = 255. 50 (green) = 5—16 + 0 = 80. 00 (blue) = 0. So #FF5000 equals rgb(255, 80, 0) ” an orange. The reverse (RGB ’ HEX) divides each channel by 16: 255 / 16 = 15 remainder 15 ’ FF; 80 / 16 = 5 remainder 0 ’ 50.

Browsers do exactly this with bit shifts: r = (n >> 16) & 0xFF, g = (n >> 8) & 0xFF, b = n & 0xFF. The math is identical whether you do it by hand, in a spreadsheet, or with this converter.

Accuracy and limitations

HEX to RGB conversion is mathematically lossless. Every #RRGGBB value maps to exactly one rgb(r, g, b) triplet, and every rgb() triplet maps back to exactly one #RRGGBB. There is no rounding, no approximation, and no error.

Two practical notes. First, three-digit shorthand like #F00 is equivalent to #FF0000 ” the browser duplicates each digit. If your input uses shorthand, expand it before converting. Second, HEX and RGB both describe the same sRGB color space. Neither can express out-of-gamut colors like Display P3 or Rec. 2020 ” for those you must use rgb(display-p3 ) in CSS instead.

Use cases

Common mistakes

HEX vs RGB at a glance

AttributeHEXRGB
Format#RRGGBBrgb(R, G, B)
Digitsbase 16base 10
Length7 chars12“20 chars
Native CSSyesyes
Best forstatic valuescomputed values

Frequently asked questions

How do I convert HEX to RGB manually?

Drop the leading # symbol, split the six digits into three pairs (RR, GG, BB), and convert each pair from base 16 to base 10. For example #FF5000 becomes FF’255, 50’80, 00’0, which is rgb(255, 80, 0).

Is HEX to RGB conversion exact?

Yes. Every #RRGGBB value maps to exactly one rgb(r, g, b) triplet, and every RGB triplet in the 0“255 range maps back to exactly one #RRGGBB. No rounding or approximation is involved.

What is the difference between #FF0000 and #F00?

They are the same color. Three-digit shorthand duplicates each digit, so #F00 expands to #FF0000 and both equal rgb(255, 0, 0), pure red. Browsers accept either form; this converter accepts both.

Does HEX to RGB change the color?

No. HEX and RGB are two notations for the same sRGB color. The color seen on screen is identical after conversion ” only the way the value is written changes.

Can I use rgb() directly in CSS?

Yes. rgb(255, 0, 0) is valid CSS and is required when you need alpha transparency via rgba(). HEX8 (#RRGGBBAA) is an alternative but has slightly less browser support in older tooling.

Related converters

Last reviewed: