How to Convert HEX to RGB (and Back)
By the 325Tools Team · Updated 2026-07-18
What does #1E90FF actually mean, and how do you get from there to rgb(30, 144, 255)? A hex color and an RGB color are the same three numbers written two ways — once you see the pattern, converting either direction is quick. Or skip the arithmetic entirely with the Color Converter.
The format: #RRGGBB
A hex color is # followed by six hex digits, in three pairs:
- RR — the red channel
- GG — the green channel
- BB — the blue channel
Each pair is a two-digit hexadecimal (base-16) number from 00 to FF, which is 0 to 255 in decimal. So each channel has 256 possible values, giving the familiar 16.7 million colors. #000000 is black (all zero), #FFFFFF is white (all max), #FF0000 is pure red.
The math (hex pair → decimal)
To convert one pair, multiply the first digit by 16 and add the second, using A=10, B=11, C=12, D=13, E=14, F=15.
Worked example — #1E90FF:
1E→ (1 × 16) + 14 = 30 (red)90→ (9 × 16) + 0 = 144 (green)FF→ (15 × 16) + 15 = 255 (blue)
So #1E90FF = rgb(30, 144, 255) (that's "dodger blue"). Going the other way, divide each channel by 16: the quotient is the first hex digit, the remainder is the second. 30 ÷ 16 = 1 remainder 14 → 1E.
The 3-digit shorthand
CSS also allows a 3-digit form where each digit is doubled: #19E expands to #1199EE. Shorthand only works when both digits of every pair match — #FFF = #FFFFFF, but a color like #1E90FF has no 3-digit form.
Alpha and 8-digit hex
Modern CSS supports an alpha (opacity) channel as a fourth pair: #RRGGBBAA. Here AA runs 00 (fully transparent) to FF (fully opaque), matching rgba()'s 0–1 range — so #1E90FF80 is dodger blue at about 50% opacity (0x80 = 128 ≈ 0.5). Pick colors visually with the Image Color Picker, pull a whole scheme from an image with the Color Palette Extractor, or blend colors with the CSS Gradient Generator.
Common mistakes
- Forgetting hex is base 16, not base 10.
FFis 255, not 15 or 99.10in hex is 16 in decimal — an easy slip that turns a bright color muddy. - Reversing the alpha scale. In
#RRGGBBAA,00is transparent andFFis opaque — the opposite of what people guess when they think "00 means off." - Mixing up 3-digit and 6-digit forms.
#123is#112233, not#123000. When in doubt, always write the full six digits, or let the Color Converter expand it for you. - Assuming rgb() takes percentages. Standard
rgb()values are 0–255 integers;rgb(30, 144, 255)is right, whilergb(12%, 56%, 100%)is a different (percentage) syntax people conflate with it.