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| RGB | rgb(255, 215, 0) | |
|---|---|---|
| HSL | hsl(51, 100%, 50%) | |
| HSV | hsv(51, 100%, 100%) | |
| HWB | hwb(51 0% 0%) | |
| CMYK | cmyk(0, 16, 100, 0) | |
| OKLCH | oklch(0.89 0.18 95) | |
| OKLAB | oklab(0.887 -0.017 0.181) | |
| LAB | lab(87.5 2.9 86.6) | |
| LCH | lch(87.5 86.6 88) | |
| DECIMAL | 16766720 | |
| ≈ | 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
| color | HEX | RGB |
|---|---|---|
| White | #FFFFFF | rgb(255, 255, 255) |
| Black | #000000 | rgb(0, 0, 0) |
| Red | #FF0000 | rgb(255, 0, 0) |
| Lime | #00FF00 | rgb(0, 255, 0) |
| Blue | #0000FF | rgb(0, 0, 255) |
| Yellow | #FFFF00 | rgb(255, 255, 0) |
| Cyan | #00FFFF | rgb(0, 255, 255) |
| Magenta | #FF00FF | rgb(255, 0, 255) |
| Gray | #808080 | rgb(128, 128, 128) |
| Orange | #FFA500 | rgb(255, 165, 0) |
| Purple | #800080 | rgb(128, 0, 128) |
| Gold | #FFD700 | rgb(255, 215, 0) |
| HEX | RGB | |
|---|---|---|
| White | #FFFFFF | rgb(255, 255, 255) |
| Black | #000000 | rgb(0, 0, 0) |
| Red | #FF0000 | rgb(255, 0, 0) |
| Green | #008000 | rgb(0, 128, 0) |
| Blue | #0000FF | rgb(0, 0, 255) |
| Yellow | #FFFF00 | rgb(255, 255, 0) |
| Orange | #FFA500 | rgb(255, 165, 0) |
| Purple | #800080 | rgb(128, 0, 128) |
| Pink | #FFC0CB | rgb(255, 192, 203) |
| Gray | #808080 | rgb(128, 128, 128) |
| Gold | #FFD700 | rgb(255, 215, 0) |
| Navy blue | #000080 | rgb(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.