Convert HEX to RGBA
What is HEX to RGBA?
HEX and RGBA are two CSS color notations. HEX uses a hexadecimal string like #E91E63 to encode the red, green, and blue channels of a color in two-digit pairs (00–FF, equivalent to 0–255). It is compact and widely used in design tools, but the standard 6-digit form cannot express transparency.
RGBA stands for Red, Green, Blue, Alpha. It expresses the same color as rgba(233, 30, 99, 1), with three integer channels (0–255) plus an alpha value from 0 (fully transparent) to 1 (fully opaque). Converting HEX to RGBA is essential whenever you need a semi-transparent version of a brand or design color in CSS — for overlays, tinted backgrounds, hover states, or shadows.
How to Convert HEX to RGBA
The conversion is purely mathematical: split the HEX string into red, green, and blue pairs, convert each pair from base-16 to base-10, then append an alpha value.
- Strip the leading
#if present. Example:#E91E63becomesE91E63. - If the code is 3 digits (
#RGB), expand each digit by duplicating it.#abcbecomesaabbcc. - Split into three pairs: red
E9, green1E, blue63. - Convert each pair from hexadecimal to decimal.
E9= 233,1E= 30,63= 99. - Pick an alpha value between 0 and 1. Use
1for fully opaque or0.5for 50% transparency. - Combine:
rgba(233, 30, 99, 1).
For 8-digit HEX codes like #E91E6380, the last pair 80 represents alpha. Convert it to decimal (128) and divide by 255 to get the 0–1 alpha value (≈ 0.50).
Common HEX to RGBA Examples
A reference of popular colors with their HEX, RGBA at full opacity, and RGBA at 50% transparency.
| Color | HEX | RGBA (100%) | RGBA (50%) | |
|---|---|---|---|---|
| Red | #FF0000 | rgba(255, 0, 0, 1) | rgba(255, 0, 0, 0.5) | |
| Green | #00FF00 | rgba(0, 255, 0, 1) | rgba(0, 255, 0, 0.5) | |
| Blue | #0000FF | rgba(0, 0, 255, 1) | rgba(0, 0, 255, 0.5) | |
| Black | #000000 | rgba(0, 0, 0, 1) | rgba(0, 0, 0, 0.5) | |
| White | #FFFFFF | rgba(255, 255, 255, 1) | rgba(255, 255, 255, 0.5) | |
| Tailwind red-500 | #EF4444 | rgba(239, 68, 68, 1) | rgba(239, 68, 68, 0.5) | |
| Tailwind blue-500 | #3B82F6 | rgba(59, 130, 246, 1) | rgba(59, 130, 246, 0.5) | |
| Tailwind green-500 | #22C55E | rgba(34, 197, 94, 1) | rgba(34, 197, 94, 0.5) | |
| Material Indigo 500 | #3F51B5 | rgba(63, 81, 181, 1) | rgba(63, 81, 181, 0.5) | |
| Material Pink 500 | #E91E63 | rgba(233, 30, 99, 1) | rgba(233, 30, 99, 0.5) | |
| Twitter / X blue | #1DA1F2 | rgba(29, 161, 242, 1) | rgba(29, 161, 242, 0.5) | |
| Facebook blue | #1877F2 | rgba(24, 119, 242, 1) | rgba(24, 119, 242, 0.5) | |
| GitHub black | #24292E | rgba(36, 41, 46, 1) | rgba(36, 41, 46, 0.5) | |
| YouTube red | #FF0000 | rgba(255, 0, 0, 1) | rgba(255, 0, 0, 0.5) | |
| Slack purple | #4A154B | rgba(74, 21, 75, 1) | rgba(74, 21, 75, 0.5) | |
| Spotify green | #1DB954 | rgba(29, 185, 84, 1) | rgba(29, 185, 84, 0.5) | |
| Bootstrap primary | #0D6EFD | rgba(13, 110, 253, 1) | rgba(13, 110, 253, 0.5) |
Why Use RGBA Instead of HEX?
Choose RGBA whenever you need transparency. Standard 6-digit HEX has no alpha channel, so it cannot produce semi-transparent colors. RGBA is the practical default for:
- Overlays and modals —
rgba(0, 0, 0, 0.5)for a dimmed background. - Hover and focus states — fading a brand color to 80% on interaction.
- Soft shadows —
box-shadowtypically uses RGBA with low alpha. - Tinted backgrounds — layering a color over an image without obscuring it.
- Glassmorphism / frosted UI — semi-transparent panels combined with
backdrop-filter.
HEX remains useful for solid colors and for design tokens, but most production CSS ends up mixing both. The 8-digit HEX form (#RRGGBBAA) does support alpha and is supported by all modern browsers, though many developers still prefer RGBA for readability when alpha is involved.
FAQ
#RRGGBBAA includes an alpha pair after the RGB pairs. For example, #FF000080 is red at 50% transparency. All evergreen browsers (Chrome, Firefox, Safari, Edge) support it. The classic 6-digit form does not.0 (fully transparent) to 1 (fully opaque). A value of 0.5 means the color is 50% transparent — the layer behind it shows through. In 8-digit HEX, alpha is encoded in the last pair as 00–FF (0–255).#abc becomes #aabbcc. Then convert each pair to decimal — aa = 170, bb = 187, cc = 204 — and add alpha. The final result is rgba(170, 187, 204, 1). The converter above handles this automatically.color, background, border, box-shadow, gradient stops, and SVG fills.rgb(255, 0, 0) is solid red; rgba(255, 0, 0, 0.5) is the same red at 50% opacity. In modern CSS, the rgb() function also accepts a fourth alpha argument, so the two functions overlap in capability.