HEX to RGB Converter
A six-digit HEX color stores red, green, and blue as three two-digit hexadecimal values. Converting each pair from base 16 gives the RGB channels from 0 to 255.
Worked example
- Input
- #336699
- Output
- rgb(51, 102, 153)
- Calculation
- R = 0x33 = 51; G = 0x66 = 102; B = 0x99 = 153
How the conversion works
Remove the leading #, split the remaining six digits into RR, GG, and BB, then convert each pair from hexadecimal to decimal. Three-digit HEX first doubles each digit, so #369 becomes #336699.
Important note
Eight-digit HEX adds an alpha pair after RGB. Alpha changes opacity but does not change the three RGB channel values.