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

Steps

  1. 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 33
  2. Convert the red pair

    Type FF into Number. The decimal row shows 255, the maximum, so this colour has full red.

  3. Convert green and blue

    Type 57 to get 87, then 33 to get 51. The colour is rgb(255, 87, 51), a bright orange-red.

  4. 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.

Try it now

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 #F53 is short for #FF5533. Double each digit before converting.
Including the alpha channel
Eight-digit codes like #FF573380 have a fourth pair for opacity. 80 is 128, about 50% opacity.

Next steps

Go back to the Number Base Converter, or keep going with one of these: