Using the converter
Paste a hex code with 3, 4, 6 or 8 digits, with or without the #. The rgba() value appears with its opacity written to three decimal places, so it turns back into exactly the same hex code.
The swatch sits on a grey and white chequerboard, the way image editors show transparency, and the rows below give the same colour in the newer slash syntax, as a percentage, and as the solid colour it makes on white or black.
How the alpha pair works
An 8-digit hex code is the usual six digits for red, green and blue with two more on the end for alpha. CSS Color 4 says 00 in that last pair is fully transparent and FF fully opaque. Read the pair as a number from 0 to 255, then divide by 255 to get the 0 to 1 scale that rgba() uses.
Take #FF880080. FF is 15 × 16 + 15 = 255 for red, 88 is 8 × 16 + 8 = 136 for green, and 00 is 0 for blue. The alpha pair 80 is 8 × 16 = 128, and 128 ÷ 255 = 0.502. So the colour is rgba(255, 136, 0, 0.502), an orange at a shade over half strength.
The 4-digit form doubles each digit, as the 3-digit form does. #F808 is #FF880088, and 88 is 136, so its alpha is 136 ÷ 255 = 0.533.
Opacity and the hex alpha pair
| Opacity | 0 to 1 | Hex pair | Out of 255 |
|---|---|---|---|
| 100% | 1 | FF | 255 |
| 90% | 0.9 | E6 | 230 |
| 80% | 0.8 | CC | 204 |
| 75% | 0.75 | BF | 191 |
| 70% | 0.7 | B3 | 179 |
| 60% | 0.6 | 99 | 153 |
| 50% | 0.5 | 80 | 128 |
| 40% | 0.4 | 66 | 102 |
| 30% | 0.3 | 4D | 77 |
| 25% | 0.25 | 40 | 64 |
| 20% | 0.2 | 33 | 51 |
| 10% | 0.1 | 1A | 26 |
| 5% | 0.05 | 0D | 13 |
| 0% | 0 | 00 | 0 |
rgba() or the slash syntax
CSS Color 4 treats rgba() as another name for rgb(), so rgb(255, 136, 0, 0.5) works too. The newer form drops the commas and puts the alpha after a slash, as in rgb(255 136 0 / 50%). The alpha can be a number from 0 to 1 or a percentage in either form.
All of these are the same colour. Pick whichever matches the rest of your stylesheet.
The colour it makes on white
A see-through colour has no single solid value. It depends on what is behind it. For each channel, the result is alpha × colour + (1 − alpha) × background.
For #FF880080 on white, green is 0.502 × 136 + 0.498 × 255 = 195, which is C3 in hex, and blue is 0.498 × 255 = 127, or 7F. Red stays at 255, so the flattened colour is #FFC37F. On black it is #804400. Those two rows help when a tool only takes six digits.
Common colours at 50% opacity
| Colour | 8-digit hex | rgba() | On white |
|---|---|---|---|
| Red | #FF000080 | rgba(255, 0, 0, 0.502) | #FF7F7F |
| Orange | #FFA50080 | rgba(255, 165, 0, 0.502) | #FFD27F |
| Yellow | #FFFF0080 | rgba(255, 255, 0, 0.502) | #FFFF7F |
| Lime | #00FF0080 | rgba(0, 255, 0, 0.502) | #7FFF7F |
| Green | #00800080 | rgba(0, 128, 0, 0.502) | #7FBF7F |
| Cyan | #00FFFF80 | rgba(0, 255, 255, 0.502) | #7FFFFF |
| Blue | #0000FF80 | rgba(0, 0, 255, 0.502) | #7F7FFF |
| Navy | #00008080 | rgba(0, 0, 128, 0.502) | #7F7FBF |
| Purple | #80008080 | rgba(128, 0, 128, 0.502) | #BF7FBF |
| Magenta | #FF00FF80 | rgba(255, 0, 255, 0.502) | #FF7FFF |
| Pink | #FFC0CB80 | rgba(255, 192, 203, 0.502) | #FFDFE5 |
| Brown | #A52A2A80 | rgba(165, 42, 42, 0.502) | #D29494 |
| White | #FFFFFF80 | rgba(255, 255, 255, 0.502) | #FFFFFF |
| Silver | #C0C0C080 | rgba(192, 192, 192, 0.502) | #DFDFDF |
| Grey | #80808080 | rgba(128, 128, 128, 0.502) | #BFBFBF |
| Black | #00000080 | rgba(0, 0, 0, 0.502) | #7F7F7F |
Questions
What alpha does a 6-digit hex code have?
Full opacity, 1 or 100%. A hex code without an alpha pair is always solid, so the converter gives rgba(…, 1).
Why is 80 not exactly 0.5?
Half of 255 is 127.5, which isn't a whole number. 80 is 128, a shade over half, and 7F is 127, a shade under. Either looks the same on screen.
Does every browser read 8-digit hex?
It is part of CSS Color 4, which current browsers follow. If a program only takes six digits, use the flattened colour from the rows instead.
Is the alpha first or last?
Last in CSS: #RRGGBBAA. Android colour resources put it first, #AARRGGBB, so #80FF8800 in an Android file is the same as #FF880080 in CSS.
Sources
Added and reviewed . What's new






