HEX to RGB Converter

You have a hex code, from a design document, screen shot, or style guide, but the tool you're working in only takes RGB.

The conversion between the two is not difficult, if you understand the pattern; and you do not have to perform the calculations by hand. Get a HEX-to-RGB conversion instantly, with just a single inputted HEX code.

HEX Conversion

What's the Difference Between HEX and RGB?

They are not two colors, they are two different ways of writing down this one exact same color.

Hex is a 6 digit code written in hexadecimal (base-16) notation: #RRGGBB, where each digit is a hex digit from 0 to F. It's a common format in HTML, CSS, and most design programs since it is short and simple to copy and paste.

RGB is composed of red, green and blue, all of which are a number between 0 and 255, such as rgb(255, 87, 51). It is the format that most programming languages, canvas APIs and photo editing tools expect when you need to work with the colors channel by channel.

Both formats are equally "accurate". They do not change the value of the red, green and blue light, just like HEX does not wrap the values in pairs of hexadecimals, but rather in plain decimal format.

Convert HEX to RGB – the Formula.

HEX codes can be divided into three sets of two-digit numbers – one for each color channel:

#RRGGBB
 ↑↑ ↑↑ ↑↑
 R   G   B

To convert manually:

  1. Divide the hex code into three groups of two hex digits. For #3E6EF7, that's 3E, 6E, and F7.
  2. Change each pair to decimal. Each pair is from 00 (0 decimal) to FF (255 decimal).
  3. Read the three results: Red, Green, Blue.

Worked Example

Converting #3E6EF7:

Hex pair Decimal value Channel
3E 62 Red
6E 110 Green
F7 247 Blue

Result: rgb(62, 110, 247)

A quick example of using pure colors.

  • #FF0000 = rgb(255, 0, 0) β€” pure red
  • #00FF00 = rgb(0, 255, 0) β€” pure green
  • #0000FF = rgb(0, 0, 255) β€” pure blue
  • #FFFFFF = rgb(255, 255, 255) β€” white
  • #000000 = rgb(0, 0, 0) β€” black
  • #808080 = rgb(128, 128, 128) β€” mid gray

Every pair of hex has a maximum of FF, which is equal to 255 in decimal β€” that's why 255 is the maximum value for each RGB channel.

Shorthand HEX Codes

Occasionally you will see a three character hex code such as #3EF. Shorthand: #3EF becomes #33EEFF before being converted. #3EF translates to rgb(51, 238, 255) and not from the three characters themselves.

What About HEX with transparency (HEX8 / RGBA)?

An 8 character hex code such as #3E6EF7CC contains a fourth pair (alpha β€” opacity) which works the same (hex pair to decimal), but is represented as a fraction of 0 to 1 instead of 0 to 255. CC in hex is 204 in decimal, and 204 Γ· 255 β‰ˆ 0.8, so #3E6EF7CC becomes rgba(62, 110, 247, 0.8).

You might need to convert HEX to RGB because:

  • Tools for designing in CSS only, that present only that format. Some plugins/older codebases require RGB, not hex.
  • Programmatic color manipulation. RGB channels are used directly by many APIs for Canvas, image-processing libraries, and many programming languages, because it is simpler to blend, lighten or darken a color by modifying three numbers.
  • Matching colors between software programs. The photo-editing, video and some design applications come with RGB sliders instead of a hex input field.
  • Adding transparency. When creating RGBA values for semi-transparent overlays, it is better to begin with the RGB value(s) instead of the hex code.

Frequently Asked Questions

Without a calculator, how to convert HEX to RGB?

Divide the Hex number into three 2-digit parts, convert each 2-digit part to base-10. Each hex digit is a number 0-15; the first digit of a pair corresponds to the 16's place in a decimal number while the second digit represents the ones place β€” e.g., 3E = (3 Γ— 16) + 14 = 62.

Is RGB more accurate than HEX?

No, they are identical in color value, but different in spelling. HEX is a shorthand for the same red, green, and blue numbers that RGB writes out directly in decimal, except in this case it's in hexadecimal. Converting from one to another never alters the actual color.

What is the meaning of a 3-digit hex code?

It's shorthand notation because each character is repeated to make the full 6 digit code. The #FFF expands to #FFFFFF (white) and #3EF expands to #33EEFF (white, white, yellow before turning into RGB).

How to convert HEX to RGBA with transparency?

The fourth pair is alpha, and is included in an 8-character hex code. Convert that pair to decimal as the others, then divide by 255 to obtain an opacity 0–1 value. A final pair of 80 (128 in decimal) will be approximately halfway opaque.

Why aren't all tools the same RGB value for an identical HEX code?

This typically involves color space or rounding issues such as showing RGB data on the standard 0–255 sRGB scale, and showing percentage or perceptually adjusted values. The basic sRGB conversion is needed for β€œregular” Web and design use: 0–255 sRGB.

Final Thoughts

HEX and RGB are two ways of indicating the same color data so there is no gain or loss of color information in making the conversion from one to the other. Whether it's a brand color that only accepts RGB values to be pasted into code or an RGBA value to be used for a transparent overlay, it only takes seconds to understand the pattern: split, convert each pair, read off red, green, and blue.

Share This Tool

Browser Extension

Get quick access to remove the gemini watermark from the image and video directly from your browser toolbar.