HEX to RGB converter

Split the HEX code into three pairs and read each as a number from 0 to 255: #FFD700 → FF, D7, 00 → rgb(255, 215, 0).

#FFD700
RGBrgb(255, 215, 0)
HSLhsl(51, 100%, 50%)
HSVhsv(51, 100%, 100%)
HWBhwb(51 0% 0%)
CMYKcmyk(0, 16, 100, 0)
OKLCHoklch(0.89 0.18 95)
OKLABoklab(0.887 -0.017 0.181)
LABlab(87.5 2.9 86.6)
LCHlch(87.5 86.6 88)
DECIMAL16766720
≈Gold

Free·No sign-up·Works offline after the first visit

  • 1. Remove the hash and split the code into pairs: FF · D7 · 00.
  • 2. In each pair, multiply the first digit by 16 and add the second. A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.
  • 3. FF = 15 × 16 + 15 = 255; D7 = 13 × 16 + 7 = 215; 00 = 0.
  • 4. Write the result as rgb(255, 215, 0). A 3-digit code such as #F80 doubles each digit first: #FF8800.

Common colors in HEX and RGB

colorHEXRGB
White#FFFFFFrgb(255, 255, 255)
Black#000000rgb(0, 0, 0)
Red#FF0000rgb(255, 0, 0)
Lime#00FF00rgb(0, 255, 0)
Blue#0000FFrgb(0, 0, 255)
Yellow#FFFF00rgb(255, 255, 0)
Cyan#00FFFFrgb(0, 255, 255)
Magenta#FF00FFrgb(255, 0, 255)
Gray#808080rgb(128, 128, 128)
Orange#FFA500rgb(255, 165, 0)
Purple#800080rgb(128, 0, 128)
Gold#FFD700rgb(255, 215, 0)
HEXRGB
White#FFFFFFrgb(255, 255, 255)
Black#000000rgb(0, 0, 0)
Red#FF0000rgb(255, 0, 0)
Green#008000rgb(0, 128, 0)
Blue#0000FFrgb(0, 0, 255)
Yellow#FFFF00rgb(255, 255, 0)
Orange#FFA500rgb(255, 165, 0)
Purple#800080rgb(128, 0, 128)
Pink#FFC0CBrgb(255, 192, 203)
Gray#808080rgb(128, 128, 128)
Gold#FFD700rgb(255, 215, 0)
Navy blue#000080rgb(0, 0, 128)

How to convert HEX to RGB by hand

A HEX color code such as #1F5BFF holds three two-digit numbers in base 16: 1F for red, 5B for green and FF for blue. To get RGB, turn each pair into an ordinary number: the first digit counts sixteens, the second counts ones. 1F = 1 × 16 + 15 = 31; 5B = 5 × 16 + 11 = 91; FF = 255. So #1F5BFF is rgb(31, 91, 255).

For RGBA, add the alpha as a number from 0 to 1. An 8-digit HEX such as #1F5BFF80 has the alpha in the last pair: 80 = 128, and 128 ÷ 255 ≈ 0.5, so it is rgba(31, 91, 255, 0.5). Without a fourth pair, the alpha is 1, fully opaque.

In code

In JavaScript: parseInt("D7", 16) gives 215. In Python: tuple(int(h[i:i+2], 16) for i in (0, 2, 4)) turns "FFD700" into (255, 215, 0). In CSS you don't need to convert at all: #FFD700 and rgb(255 215 0) are the same color.

Questions and answers

How do I change HEX to RGB?

Split the code into three pairs and convert each from base 16: #FFD700 → 255, 215, 0.

How do I convert HEX to RGBA?

Convert the three pairs, then add the alpha: 1 for opaque, or the last pair ÷ 255 for an 8-digit code.

How do I convert HEX to RGB in Python?

Use tuple(int(h[i:i+2], 16) for i in (0, 2, 4)) on the code without the hash.

Can I get HEX to RGB and CMYK at once?

Yes. The converter shows RGB, CMYK, HSL and more for every HEX code you type.