Number Base Converter · Tutorial
How to convert hex colour codes to decimal RGB values
4 min readbeginnerUpdated
Design tools give you colours as hex codes, but some software, spreadsheets and APIs want separate red, green and blue numbers. This tutorial splits #FF5733 into its three pairs and converts each one to decimal.
What you need
- The Number Base Converter
- A six-digit hex colour code
Steps
Split the code into pairs
Drop the
#and split the six digits into three pairs. The first is red, the second green and the third blue.FF 57 33Convert the red pair
Type
FFinto Number. The decimal row shows 255, the maximum, so this colour has full red.Convert green and blue
Type
57to get 87, then33to get 51. The colour isrgb(255, 87, 51), a bright orange-red.Know what the full number means
If you convert all six digits at once (the Try it button loads
0xFF5733) you get 16,734,003. Some systems store colours as this single integer.
Try it yourself
Opens the Number Base Converter with this tutorial's sample loaded.
Common mistakes
- Converting the whole code when you need RGB
- For RGB values, convert each pair separately. The six-digit number is a different representation.
- Three-digit shorthand
- A code like
#F53is short for#FF5533. Double each digit before converting. - Including the alpha channel
- Eight-digit codes like
#FF573380have a fourth pair for opacity.80is 128, about 50% opacity.
Next steps
Go back to the Number Base Converter, or keep going with one of these: