Convert HEX to RGBA with alpha
This HEX to RGBA converter turns hex color codes into CSS rgba() values, including the transparency stored in eight-digit hex. A plain #RRGGBB code becomes fully opaque with alpha 1, while #RRGGBBAA keeps its alpha as a decimal between 0 and 1.
How the alpha byte becomes a decimal
In an eight-digit code the last pair is alpha. Like the color pairs, it is a byte from 00 to FF, and CSS alpha is that byte divided by 255. The tool rounds the result to three decimal places.
#0F766E80
0F = 15 76 = 118 6E = 110 80 = 128
alpha = 128 / 255 = 0.502
→ rgba(15, 118, 110, 0.502)
Notice that 80 gives 0.502, not exactly 0.5. Because 255 is odd, no byte lands precisely on one half. The table lists the alpha bytes you will meet most often.
| Hex byte | Decimal | rgba() alpha |
|---|---|---|
| FF | 255 | 1 |
| E6 | 230 | 0.902 |
| CC | 204 | 0.8 |
| BF | 191 | 0.749 |
| 99 | 153 | 0.6 |
| 80 | 128 | 0.502 |
| 66 | 102 | 0.4 |
| 40 | 64 | 0.251 |
| 33 | 51 | 0.2 |
| 1A | 26 | 0.102 |
| 00 | 0 | 0 |
Four-digit shorthand
CSS also allows #RGBA, where each digit is doubled just like in #RGB. #abcd expands to #aabbccdd: red 170, green 187, blue 204 and alpha 221 ÷ 255 = 0.867, giving rgba(170, 187, 204, 0.867).
Why convert to RGBA at all?
Current browsers understand eight-digit hex, so CSS doesn't strictly require the conversion. RGBA is simply easier to read and edit: 0.4 is obviously 40% opaque, while 66 needs a lookup. It is also the form many JavaScript libraries, canvas code and design handoff notes expect.
Once a color is in RGBA you can change its opacity by editing one number, for example turning a solid brand color into a faint tint for a hover background.
Watch the byte order
CSS puts alpha last. Android color resources and XAML put it first (#AARRGGBB). If you paste #800F766E from an Android project, this tool reads it the CSS way: red 128, green 15, blue 118 and alpha 0.431, a completely different color. Move the first pair to the end before converting.
To go back, the RGBA to HEX converter turns an alpha decimal into its byte again. If you only need the three color channels, HEX to RGB leaves the alpha out, and RGBA to RGB explains how to flatten a transparent color onto a background.