MartTools

Colors

How to Convert HEX to RGB

Learn how to convert HEX colors to RGB step by step, understand hexadecimal color values and use converted RGB colors in CSS and digital design.

What Is HEX to RGB Conversion?

HEX to RGB conversion changes a color from hexadecimal notation into red, green and blue channel values. Both formats can describe the same digital color; the conversion simply changes how that color is represented.

HEX values are commonly written as six hexadecimal characters, while RGB values use three decimal numbers ranging from 0 to 255.

Understanding a HEX Color

A standard six-digit HEX color begins with a hash symbol followed by six hexadecimal characters. The six characters are divided into three pairs representing red, green and blue.

For example, #3366CC contains three pairs: 33 for red, 66 for green and CC for blue.

What RGB Values Represent

RGB stands for red, green and blue. Each channel normally uses a decimal value from 0 to 255.

The first number represents red, the second represents green and the third represents blue. Combining the three values produces the final color.

HEX and RGB Use Different Number Systems

The main reason HEX to RGB conversion is necessary is that the two formats use different number systems. HEX uses base 16, while the common RGB representation uses decimal numbers in the range from 0 to 255.

The hexadecimal digits include 0 through 9 and A through F. The letters represent values from 10 through 15.

Step 1: Separate the HEX Color Into Pairs

Start by removing the # symbol and separating the remaining six characters into three two-character groups.

For #3366CC, the groups are 33, 66 and CC. These correspond to red, green and blue respectively.

Step 2: Convert the Red Pair

The first pair represents the red channel. For #3366CC, the red pair is 33.

The hexadecimal value 33 equals decimal 51, so the red RGB channel is 51.

Step 3: Convert the Green Pair

The second pair represents the green channel. For #3366CC, the green pair is 66.

The hexadecimal value 66 equals decimal 102, so the green RGB channel is 102.

Step 4: Convert the Blue Pair

The third pair represents the blue channel. For #3366CC, the blue pair is CC.

The hexadecimal value CC equals decimal 204, so the blue RGB channel is 204.

Complete HEX to RGB Example

For #3366CC, the three hexadecimal pairs convert as follows: 33 becomes 51, 66 becomes 102 and CC becomes 204.

The resulting RGB value is rgb(51, 102, 204).

How Hexadecimal Conversion Works

Each two-digit hexadecimal pair represents a value from 0 to 255. To convert a two-digit hexadecimal number to decimal, multiply the first digit by 16 and add the value of the second digit.

For example, hexadecimal 33 is calculated as 3 × 16 + 3 = 51. Hexadecimal 66 is 6 × 16 + 6 = 102. Hexadecimal CC is 12 × 16 + 12 = 204.

HEX to RGB Formula

For a two-digit hexadecimal pair, the decimal value can be calculated as (first hexadecimal digit × 16) + second hexadecimal digit.

The formula is applied separately to the red, green and blue pairs. The three resulting decimal values become the RGB channels.

Common HEX to RGB Examples

#000000 → rgb(0, 0, 0)

#FFFFFF → rgb(255, 255, 255)

#FF0000 → rgb(255, 0, 0)

#00FF00 → rgb(0, 255, 0)

#0000FF → rgb(0, 0, 255)

#3366CC → rgb(51, 102, 204)

Converting #FF6600 to RGB

The HEX color #FF6600 contains the pairs FF, 66 and 00.

FF converts to 255, 66 converts to 102 and 00 converts to 0. Therefore, #FF6600 becomes rgb(255, 102, 0).

Converting #123456 to RGB

The HEX color #123456 contains the pairs 12, 34 and 56.

12 converts to 18, 34 converts to 52 and 56 converts to 86. Therefore, #123456 becomes rgb(18, 52, 86).

Short HEX Colors

CSS also supports three-digit HEX notation such as #369. Each digit is expanded to create the corresponding six-digit value.

For example, #369 expands to #336699. The expanded value can then be converted to RGB using the same process.

HEX Colors With Alpha

Some color systems and CSS syntax support an eight-digit HEX value in which the final two characters represent an alpha channel. The first six characters still represent red, green and blue.

When converting an eight-digit HEX value to standard RGB, the RGB portion can be converted normally. If transparency needs to be preserved, an RGBA or other alpha-supporting format may be more appropriate.

Using HEX to RGB Conversion in CSS

RGB values can be used directly in CSS. For example, the HEX color #3366CC can be written as rgb(51, 102, 204).

A CSS declaration can therefore use color: rgb(51, 102, 204); when the RGB representation is preferred or required by the project.

Why Convert HEX to RGB?

Converting HEX to RGB can be useful when working with software, code or design systems that require separate red, green and blue channel values.

RGB values can also be easier to manipulate programmatically when a project needs to work with individual color channels.

Manual Conversion vs a Color Converter

Manual conversion is useful when you want to understand how HEX colors work or verify a result. For repeated conversions, an online color converter is usually faster and reduces calculation effort.

A color tool can convert the values automatically and provide a result that can be copied directly into a project.

Common HEX to RGB Conversion Mistakes

One common mistake is reading hexadecimal values as if they were decimal numbers. For example, hexadecimal 33 is decimal 51, not decimal 33.

Another mistake is mixing up the channel order. The first HEX pair is red, the second is green and the third is blue.

How to Verify a Converted Color

After converting a HEX value to RGB, you can compare the original and converted values in a color picker or design tool. If the conversion is correct, both representations should describe the same color.

For example, #3366CC and rgb(51, 102, 204) should produce the same intended color when used correctly.

How MartTools Color Tools Can Help

MartTools Color Tools can help you convert color values without performing the hexadecimal calculations manually. Enter the color value, review the corresponding representation and copy the result for your project.

You can also use the related MartTools guides to learn more about HEX, RGB and HSL color formats and practical color selection.

Related tool

Put this guide into practice

Related guides

Frequently asked questions

How do I convert HEX to RGB?

Separate the six-digit HEX value into three two-character pairs, convert each hexadecimal pair to a decimal value from 0 to 255, then place the three values into an RGB color.

What is #3366CC in RGB?

#3366CC is rgb(51, 102, 204).

What is #FF6600 in RGB?

#FF6600 is rgb(255, 102, 0).

What is #123456 in RGB?

#123456 is rgb(18, 52, 86).

What is the HEX to RGB formula?

For each two-digit HEX pair, multiply the first hexadecimal digit by 16 and add the value of the second digit. Apply this separately to the red, green and blue pairs.

What number system does HEX use?

HEX color notation uses the hexadecimal, or base-16, number system. It uses digits 0 through 9 and letters A through F.

What range do RGB values use?

In the common RGB notation used for CSS, each red, green and blue channel uses a value from 0 to 255.

Can I convert a three-digit HEX color to RGB?

Yes. Expand the three-digit HEX value into its six-digit equivalent first, then convert the three pairs to RGB values.

Can HEX include transparency?

Yes. Some CSS color notation supports eight-digit HEX values, with the final two hexadecimal characters representing alpha or transparency.

Why would I convert HEX to RGB?

HEX to RGB conversion can be useful when software, code or a design workflow requires separate red, green and blue channel values.

Can I convert HEX to RGB without a calculator?

Yes. You can convert each hexadecimal pair manually using base-16 arithmetic, although a color converter is faster for repeated conversions.

Is HEX to RGB conversion exact?

Yes. Standard six-digit HEX colors can be converted exactly to their corresponding 0-to-255 RGB channel values.

← More guides