How Hex to RGB Conversion Works: The Math Behind It
- A hex color is three base-16 numbers written back to back — two characters per channel.
- Convert each two-character pair from base 16 to base 10 to get the RGB value for that channel.
- FF in hex = 255 in decimal (maximum), 00 in hex = 0 (minimum).
- Paste any hex code into the converter above to see the result without doing the math by hand.
Table of Contents
A hex color code like #3B82F6 is three hexadecimal numbers written one after another — two characters for red, two for green, two for blue. Converting to RGB means converting each of those pairs from base 16 (hexadecimal) to base 10 (decimal). The result is three numbers between 0 and 255 that your screen uses to mix the final color.
You do not need to do this math manually — the converter handles it instantly — but understanding the process makes you better at working with color systems in design and code.
What Hexadecimal Actually Means
Decimal (the number system you use every day) has 10 symbols: 0 through 9. Hexadecimal has 16 symbols: 0 through 9, then A through F.
- A = 10, B = 11, C = 12, D = 13, E = 14, F = 15
- 10 in hex = 16 in decimal
- FF in hex = 255 in decimal
- 80 in hex = 128 in decimal
Two hex digits can represent 256 values (0-255) — exactly the range needed for one RGB color channel. That is not a coincidence — RGB and hex use the same underlying data, just in different notation.
How to Read a Hex Color Code
Take #3B82F6 and split it into three pairs:
3B= red channel82= green channelF6= blue channel
The # sign is just a convention to mark that this is a hex color — it is not part of the number itself. Remove it before doing any math.
Sell Custom Apparel — We Handle Printing & Free ShippingThe Actual Conversion Math
Each hex pair has two digits. The first digit is multiplied by 16, the second by 1. Add the two results together.
For 3B: 3 is the first digit (decimal value 3), B is the second digit (decimal value 11).
- 3 × 16 = 48
- 11 × 1 = 11
- 48 + 11 = 59
For 82: 8 × 16 = 128, 2 × 1 = 2, total = 130.
For F6: F = 15, so 15 × 16 = 240. 6 × 1 = 6. Total = 246.
Final result: rgb(59, 130, 246) — a medium blue.
Common Hex-to-Decimal Reference Points
A few values to internalize make mental conversions faster:
00= 0 (minimum — none of this channel)80= 128 (middle — exactly half)FF= 255 (maximum — full intensity)40= 64 (one quarter)BF= 191 (three quarters)
So a color like #FF8000 is immediately readable as full red, half green, no blue — an orange. #808080 is equal parts 128/128/128 — a neutral gray. Pattern recognition comes quickly with practice.
Skip the Math
Paste any hex code above and get the exact RGB values instantly — no base-16 arithmetic needed.
Open Hex to RGB ConverterFrequently Asked Questions
Why does RGB use 0 to 255 instead of 0 to 100?
255 is the maximum value of a single byte of data (8 bits). Using one byte per channel is computationally efficient and goes back to early computer display hardware. Two hex digits also happen to represent exactly 256 values, making hex and RGB a natural match.
What is the maximum hex value for two digits?
FF, which equals 255 in decimal. F is 15 in hex, so FF = (15 x 16) + 15 = 240 + 15 = 255. This is why white is #FFFFFF — maximum red, green, and blue simultaneously.
Is hex color the same as hexadecimal in programming?
Yes. Hex color codes use exactly the same hexadecimal number system used in programming, memory addresses, and binary data. The color #FF0000 uses the same base-16 representation as the hexadecimal number 0xFF0000.
Can I estimate RGB values from a hex code without calculating?
Yes, with practice. The first digit of each pair gives a rough approximation: 0x = 0-15, 4x = 64-79, 8x = 128-143, Cx = 192-207, Fx = 240-255. For quick estimates, multiply the first digit by 16 and you will be close.

