Color conversion
How to convert HEX to RGB
A six-digit HEX color stores red, green, and blue as three hexadecimal pairs. Convert each pair from base 16 to a decimal value between 0 and 255.
Open the HEX to RGB converterSplit the HEX color into channels
Remove the optional #, then separate the six digits into red, green, and blue pairs:
#FF8000 → FF | 80 | 00
Hexadecimal uses 0 to 9 followed by A to F, where A is 10 and F is 15. Each pair has a high digit worth sixteen times its value and a low digit worth its value.
Convert each pair to decimal
decimal channel = first digit × 16 + second digit
- FF: 15 × 16 + 15 = 255
- 80: 8 × 16 + 0 = 128
- 00: 0 × 16 + 0 = 0
The result is rgb(255, 128, 0). Letter case does not matter: ff8000 represents the same color.
Expand short HEX notation
Three-digit HEX repeats each digit before conversion. #3A7 expands to #33AA77, not #030A07. Four-digit HEX works the same way and includes alpha: #3A78 expands to #33AA7788.
Convert HEX alpha to RGBA
In eight-digit HEX, the final pair is alpha. Convert it to a decimal byte and divide by 255:
RGBA opacity = alpha byte ÷ 255
For #33669980, alpha 80 is 128, so opacity is 128 ÷ 255 ≈ 0.50196. The alpha pair comes last in CSS HEX notation.
Convert with ToolPixels
The free HEX to RGB tool accepts 3, 4, 6, or 8 hexadecimal digits, with or without #. It returns RGB for opaque input and RGBA when alpha is present.