Free tool
HEX to RGB converter
Paste a HEX color code to get its RGB value: #FF5733 is rgb(255, 87, 51). Short (#F53) and alpha codes (#FF573380) work too, and the math for every channel is shown under the result.
Free · no sign-up · runs in your browser, nothing is uploaded
- Red: FF = 15 × 16 + 15 = 255
- Green: 57 = 5 × 16 + 7 = 87
- Blue: 33 = 3 × 16 + 3 = 51
= rgb(255, 87, 51)
Each pair of hex digits is one byte: first digit × 16 + second digit. A=10, B=11, C=12, D=13, E=14, F=15.
- orange-600#f54900ΔE 3.6
- orange-500#ff6900ΔE 4.3
- red-400#ff6467ΔE 5
Distance is ΔE OK × 100 in OKLab; under about 2 is hard to tell apart. Nearest CSS name: tomato (ΔE 2.2).
WCAG 2.2: 4.5:1 for body text (AA), 3:1 for large text and UI parts, 7:1 for AAA.
Tints (+ white), 10% to 90%
Shades (+ black), 10% to 90%
How HEX to RGB conversion works
A HEX color is three bytes written in base 16, one byte per channel. Each byte is two hex digits, and each digit is worth 0 to 15 (0-9, then A=10 to F=15). The first digit counts sixteens, the second counts ones.
#FF5733 RR GG BB FF = 15 × 16 + 15 = 255 → red 57 = 5 × 16 + 7 = 87 → green 33 = 3 × 16 + 3 = 51 → blue #FF5733 = rgb(255, 87, 51)
Because two hex digits hold exactly 256 values, every HEX code maps to one RGB value and back, with no rounding. That is why the converter can show the result as exact integers.
3, 4, 6 and 8-digit HEX codes
CSS accepts four lengths. The short forms repeat each digit; the 4 and 8-digit forms add alpha (opacity) at the end.
| Form | Example | Expands to | RGB / RGBA |
|---|---|---|---|
| #RGB | #F53 | #FF5533 | rgb(255, 85, 51) |
| #RGBA | #F538 | #FF553388 | rgba(255, 85, 51, 0.533) |
| #RRGGBB | #FF5733 | #FF5733 | rgb(255, 87, 51) |
| #RRGGBBAA | #FF573380 | #FF573380 | rgba(255, 87, 51, 0.502) |
Alpha in hex is a byte too: 00 is fully transparent, FF fully opaque, and 80 (128) is 128 / 255 ≈ 0.502, a little over half. Watch out for Android and Flutter, which put alpha first (0xAARRGGBB). The converter reads 0x80FF5733 in that order.
Common HEX codes and their RGB values
| Color | HEX | RGB |
|---|---|---|
| Black | #000000 | rgb(0, 0, 0) |
| White | #FFFFFF | rgb(255, 255, 255) |
| 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 / aqua | #00FFFF | rgb(0, 255, 255) |
| Magenta / fuchsia | #FF00FF | rgb(255, 0, 255) |
| Gray | #808080 | rgb(128, 128, 128) |
| Silver | #C0C0C0 | rgb(192, 192, 192) |
| Orange | #FFA500 | rgb(255, 165, 0) |
| Tomato | #FF6347 | rgb(255, 99, 71) |
Note that CSS green is #008000 (rgb(0, 128, 0)), not #00FF00; the full-intensity green is called lime.
Convert HEX to RGB in code
JavaScript
function hexToRgb(hex) {
let h = hex.replace(/^#/, '');
if (h.length <= 4) h = [...h].map(c => c + c).join(''); // #F53 -> FF5533
const n = i => parseInt(h.slice(i, i + 2), 16);
const a = h.length === 8 ? +(n(6) / 255).toFixed(3) : 1;
return { r: n(0), g: n(2), b: n(4), a };
}
hexToRgb('#FF573380'); // { r: 255, g: 87, b: 51, a: 0.502 }Python
def hex_to_rgb(code: str) -> tuple[int, int, int]:
h = code.lstrip('#')
if len(h) == 3:
h = ''.join(c * 2 for c in h)
return tuple(int(h[i:i + 2], 16) for i in (0, 2, 4))
hex_to_rgb('#FF5733') # (255, 87, 51)Go
v, err := strconv.ParseUint(strings.TrimPrefix("#FF5733", "#"), 16, 32)
if err != nil { /* not a hex color */ }
r, g, b := uint8(v>>16), uint8(v>>8), uint8(v) // 255 87 51Bash
hex=FF5733
printf 'rgb(%d, %d, %d)\n' 0x${hex:0:2} 0x${hex:2:2} 0x${hex:4:2} # rgb(255, 87, 51)After the conversion
The tool also shows HSL, OKLCH and other formats, the nearest Tailwind color, and contrast against white and black, so you can tell right away if the color works for text. Going the other way? Use the RGB to HEX converter. For every format at once, with a custom background for the contrast check, use the color converter. To turn a single hex number into decimal, the hex to decimal converter shows the place values.
Building a design system? Browse design tools and Tailwind CSS tools launched on DevHunt.
More free developer tools
FAQ
How do I convert HEX to RGB?+
Split the code into three pairs: RR, GG and BB. Convert each pair from base 16 to base 10 by multiplying the first digit by 16 and adding the second (A=10 through F=15). #FF5733 becomes FF=255, 57=87, 33=51, so rgb(255, 87, 51).
What is #FFFFFF in RGB?+
rgb(255, 255, 255), which is white. #000000 is rgb(0, 0, 0), black. FF is the largest two-digit hex number, 15 × 16 + 15 = 255.
How do I convert an 8-digit HEX code to RGBA?+
The first six digits are red, green and blue as usual. The last pair is alpha: convert it to a number from 0 to 255 and divide by 255. #FF573380 has alpha 80 = 128, and 128 / 255 ≈ 0.5, so it is rgba(255, 87, 51, 0.5).
What does a 3-digit HEX code like #F53 mean?+
It is shorthand: every digit is written twice. #F53 is #FF5533, which is rgb(255, 85, 51). A 4-digit code works the same way with alpha: #F538 is #FF553388.
Are HEX color codes case-sensitive?+
No. #ff5733 and #FF5733 are the same color in CSS. Pick one style and keep it consistent in your codebase; formatters like Prettier leave the case as written.
What is the difference between HEX and RGB?+
Nothing about the color itself. Both describe the same 8-bit red, green and blue channels; HEX writes each channel as two base-16 digits, RGB writes it as a number from 0 to 255. Browsers treat #FF5733 and rgb(255, 87, 51) as identical.
How do I convert HEX to RGB in Excel or Google Sheets?+
With the code in A1 (like #FF5733), use =HEX2DEC(MID(A1,2,2)) for red, =HEX2DEC(MID(A1,4,2)) for green and =HEX2DEC(MID(A1,6,2)) for blue. For a list of codes, the bulk mode above is faster: paste one per line and copy the result.
Sources: CSS Color Module Level 4: hex notation · MDN: <hex-color> · MDN: rgb() · Python int() · Go strconv.ParseUint · Microsoft: HEX2DEC function. Checked 2026-10-30.