How to convert hex colours to RGB (and back)

How hex colour codes map to RGB values, how to convert them by hand in a minute, and quick ways to do it on a Mac.

By Rudra Satani, maker of NotchMind ·

How hex works

A hex colour like #0A84FF is three pairs of hexadecimal digits: red 0A, green 84, blue FF. Each pair is a number from 0 to 255.

By hand

Each pair is first digit × 16 + second digit, where A–F mean 10–15:

  • 0A = 0 × 16 + 10 = 10
  • 84 = 8 × 16 + 4 = 132
  • FF = 15 × 16 + 15 = 255

So #0A84FF is rgb(10, 132, 255).

Back to hex

Divide each value by 16: the whole part is the first digit, the remainder the second. 132 ÷ 16 = 8 remainder 4 → 84.

Short hex

#F80 is shorthand for #FF8800: each digit doubles.

Alpha

#0A84FF80 adds a fourth pair for opacity: 80 is 128, about 50%. In CSS that’s rgba(10, 132, 255, 0.5).

On a Mac

NotchMind, which I make, converts colours on its Developer Tools page, and offers Convert Color whenever you copy one. See developer tools in the notch.

About the author

Rudra Satani makes NotchMind, a notch app for Mac, so read anything about notch apps here with that in mind. Spotted a mistake? Email support@notchmind.com, or reach out at @rudraxx13.