How to convert hex to RGB
- Type or paste a hex color code into the Hex color code field, with or without
#, or click the swatch to pick a color. - Read the result as
rgb()and see the red, green and blue values on the sliders, together with HSL, HSV and CMYK. - Copy any format with one click. The formula next to the formats shows how each pair of hex digits becomes a number from 0 to 255.
Hex to RGB formula
A hex color code is three bytes written in hexadecimal: #RRGGBB. Each pair of digits is one channel from 00 (0) to FF (255). To convert a pair, multiply the first digit by 16 and add the second, counting A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15. Example for #7C3AED:
- Red:
7C= 7 × 16 + 12 = 124 - Green:
3A= 3 × 16 + 10 = 58 - Blue:
ED= 14 × 16 + 13 = 237
So #7C3AED = rgb(124, 58, 237).
Shorthand and transparent hex codes
A 3-digit code is shorthand in which every digit is doubled: #F80 = #FF8800 = rgb(255, 136, 0). An 8-digit code adds an alpha byte for opacity: in #7C3AED80 the last pair 80 = 128, and 128 ÷ 255 ≈ 0.5, so it equals rgba(124, 58, 237, 0.5). The 4-digit form #RGBA works the same way.
Common hex color codes and their RGB values
| 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) |
| Orange | #FFA500 | rgb(255, 165, 0) |
| Gray | #808080 | rgb(128, 128, 128) |
| Navy | #000080 | rgb(0, 0, 128) |
| Purple | #800080 | rgb(128, 0, 128) |
| Teal | #008080 | rgb(0, 128, 128) |
Frequently asked questions
How do I convert hex to RGB by hand?
Split the code into three pairs and convert each pair from hexadecimal: first digit × 16 + second digit. For #1E90FF: 1E = 30, 90 = 144 and FF = 255, so the color is rgb(30, 144, 255).
What does a 3-digit hex color like #F80 mean?
It is shorthand for a 6-digit code with every digit doubled: #F80 = #FF8800 = rgb(255, 136, 0). Only colors whose pairs have two equal digits can be shortened.
How do I convert hex to RGB in JavaScript or Python?
JavaScript: [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16)) for a code like #RRGGBB. Python: tuple(int(h[i:i + 2], 16) for i in (1, 3, 5)). In CSS no conversion is needed – both notations are accepted.
Is hex or RGB better for CSS?
They describe exactly the same colors. Hex is shorter and common in design tools; rgb() is easier to read and adjust and makes transparency obvious with rgba(). Modern browsers also accept 8-digit hex codes with alpha.