Developer 🔒 Runs in your browser — no data sent to servers

HEX to RGB Converter

Paste a HEX color code and get its RGB values, ready to copy as rgb() or rgba().

Input Color
Enter a color to convert...

Convert HEX Color Codes to RGB

Design files and brand guides usually give colors as HEX codes, while canvas code, SVG attributes, image libraries and CSS with transparency often want RGB numbers. The two notations describe exactly the same thing, so converting between them is lossless.

This page opens the Color Converter with HEX input selected and an example loaded. Replace it with your own code.

Diagram: the HEX colour #0A84FF split into the pairs 0A, 84 and FF, which are 10, 132 and 255 in decimal: rgb(10, 132, 255), or hsl(210, 100%, 52%).#R0A10G84132BFF255Two hex digits per channel0x84 = 8 × 16 + 4 = 132Each channel runs from 0 to 255rgb(10, 132, 255)hsl(210, 100%, 52%)
A HEX colour is three pairs of hexadecimal digits for red, green and blue. #0A84FF is rgb(10, 132, 255), and the very same colour written in HSL is hsl(210, 100%, 52%).

How the conversion works

A HEX color is three bytes written in base 16: red, green and blue. Each pair of digits ranges from 00 to FF, which is 0 to 255 in decimal. To convert a pair, multiply the first digit by 16 and add the second, where A to F stand for 10 to 15.

HEXPairsRGB
#0A84FF0A · 84 · FFrgb(10, 132, 255)
#FF5733FF · 57 · 33rgb(255, 87, 51)
#FFFFF · FF · FFrgb(255, 255, 255)
#00000000 · 00 · 00rgb(0, 0, 0)

Short codes and alpha

  • 3 digits: every digit is doubled, so #0AF is #00AAFF.
  • 4 digits: the same doubling, with the fourth digit as alpha.
  • 8 digits: the last pair is alpha from 00 (transparent) to FF (opaque), shown as rgba() with a 0–1 value.
  • The leading # is optional; lowercase and uppercase both work.

HEX to RGB in code

In JavaScript, parseInt('84', 16) returns 132, so a full conversion is three such calls on the pairs. In Python, tuple(int(h[i:i+2], 16) for i in (0, 2, 4)) does the same for a six-digit string without the #. Modern CSS accepts both notations directly, so a conversion is only needed when a tool or API insists on one of them.

Related conversions

Going the other way, RGB to HEX turns channel values back into a code. For building lighter and darker variants, HEX to HSL is usually more convenient, and the Color Contrast Checker tells you whether a color is readable on its background.