HEX to RGB Color Converter

Decode 3-digit or 6-digit hexadecimal color codes into decimal red, green, and blue channel values for CSS and digital design.

Last updated: August 2026 | By Workshelve Team

RGB Values

HEX Color Code

What Do HEX and RGB Mean?

HEX and RGB are two notations for describing colors made from red, green, and blue light. A six-digit HEX color has the structure #RRGGBB. The first pair represents red, the second green, and the third blue.

HEX uses base 16, so each digit can be 0–9 or A–F. A two-digit HEX pair ranges from 00 to FF, which corresponds exactly to decimal values from 0 to 255. That is why every #RRGGBB color maps directly to an RGB value such as rgb(6, 182, 212).

Three-digit HEX is shorthand. A value such as #0CF expands by repeating each digit: #00CCFF. This converter performs that expansion before calculating the RGB channel values.

Reading a HEX Color as RGB Channels

A six-digit HEX color is a compact way to store three color channels. In #RRGGBB, RR is red, GG is green, and BB is blue. Each pair is a base-16 number from 00 through FF, and this converter decodes those pairs into familiar decimal RGB values from 0 through 255.

HEX input is case-insensitive, so #7C3AED and #7c3aed describe the same color. The # prefix is optional, and this converter also accepts a leading 0x prefix. The result is shown as separate red, green, and blue numbers plus standard CSS rgb(r, g, b) notation.

Three-digit HEX uses shorthand rather than three full channel pairs. A code such as #0CF expands to #00CCFF by repeating each digit before conversion. That expansion is important: 0 becomes 00, C becomes CC, and F becomes FF.

How to Convert HEX to RGB

Decode Each HEX Pair

1. Normalize the color code
Remove an optional # or 0x prefix. If the code has three digits, duplicate each digit to create six digits.
2. Separate RR, GG, and BB
Read the six HEX digits as three two-character channel values.
3. Decode base 16 to decimal
For a pair XY: decimal = value(X) × 16 + value(Y). Apply that calculation independently to red, green, and blue.

Common HEX Pairs in Decimal

000
0F15
1016
4064
80128
A0160
C8200
FF255

HEX to RGB Examples

#000000
rgb(0, 0, 0)
#FFFFFF
rgb(255, 255, 255)
#0CF
rgb(0, 204, 255)
#7C3AED
rgb(124, 58, 237)

Worked example: #06B6D4

Split
06 / B6 / D4
Red
06₁₆ = 0 × 16 + 6 = 6
Green
B6₁₆ = 11 × 16 + 6 = 182
Blue
D4₁₆ = 13 × 16 + 4 = 212
Result
rgb(6, 182, 212)

HEX to RGB Frequently Asked Questions

Which HEX color formats can I decode?

The converter accepts three-digit #RGB shorthand and six-digit #RRGGBB colors. The # prefix is optional, and a leading 0x prefix is accepted as an alternative.

How is a three-digit HEX color expanded before conversion?

Each digit is repeated to form a full channel pair. #0CF becomes #00CCFF, so its RGB channels decode to 0, 204, and 255.

Do uppercase and lowercase HEX letters produce different RGB values?

No. Hexadecimal digits A–F are case-insensitive, so #7C3AED and #7c3aed decode to the same red, green, and blue values.

How is a HEX pair such as B6 converted to decimal?

B represents 11 in base 16. B6 therefore equals 11 × 16 + 6, which is 182. The same calculation is applied to the other two channel pairs.

Why can a HEX pair start with zero?

Leading zeroes are significant placeholders in a two-digit channel. For example, 06 is decimal 6, while 60 is decimal 96, so reversing those digits changes the color.

What happens if the HEX code has the wrong length or invalid characters?

The converter shows a validation error. After an optional prefix is removed, the color must contain exactly 3 or 6 hexadecimal digits using only 0–9 and A–F.

Can I paste the RGB result into CSS?

Yes. Along with the three decimal channel values, the converter provides standard rgb(r, g, b) notation suitable for CSS color properties.

Can this converter decode eight-digit HEX colors with transparency?

No. This tool is limited to opaque three-digit and six-digit HEX colors. Eight-digit #RRGGBBAA values include an alpha channel and are not accepted.

Related Tools