StringMash.com

Hex to RGBA converter

Hex codes with an alpha pair to rgba(), with the working.

Conversion
9 characters
Updates as you type
Hex#FF880080
RGBrgba(255, 136, 0, 0.502)
HSLhsla(32, 100%, 50%, 0.502)
HSV (HSB)hsv(32, 100%, 100%)
CMYKcmyk(0%, 47%, 100%, 0%)
Nearest CSS namedarkorange
Opacity0.502 (50.2%)
CSS, space syntaxrgb(255 136 0 / 50.2%)
Flattened on white#FFC37F
Flattened on black#804400
The swatch and working are below

Show the steps
Aa blackAa white
  1. Split the code into pairs: FF 88 00 80. Each pair is a number from 00 to FF, which is 0 to 255.
  2. Red: FF = 15 × 16 + 15 = 255.
  3. Green: 88 = 8 × 16 + 8 = 136.
  4. Blue: 00 = 0 × 16 + 0 = 0.
  5. Alpha: 80 = 8 × 16 + 0 = 128, and 128 ÷ 255 = 0.502 opacity.
  6. In rgba() the alpha is written from 0 (clear) to 1 (solid), so it is 0.502, or 50.2%. Rounded to 3 places, it turns back into the same hex pair.

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

Each percentage times 255, rounded to a whole number and written in hex.
Opacity0 to 1Hex pairOut of 255
100%1FF255
90%0.9E6230
80%0.8CC204
75%0.75BF191
70%0.7B3179
60%0.699153
50%0.580128
40%0.466102
30%0.34D77
25%0.254064
20%0.23351
10%0.11A26
5%0.050D13
0%0000

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

Alpha pair 80 is 128 out of 255, so these are a shade over half strength.
Colour8-digit hexrgba()On white
Red#FF000080rgba(255, 0, 0, 0.502)#FF7F7F
Orange#FFA50080rgba(255, 165, 0, 0.502)#FFD27F
Yellow#FFFF0080rgba(255, 255, 0, 0.502)#FFFF7F
Lime#00FF0080rgba(0, 255, 0, 0.502)#7FFF7F
Green#00800080rgba(0, 128, 0, 0.502)#7FBF7F
Cyan#00FFFF80rgba(0, 255, 255, 0.502)#7FFFFF
Blue#0000FF80rgba(0, 0, 255, 0.502)#7F7FFF
Navy#00008080rgba(0, 0, 128, 0.502)#7F7FBF
Purple#80008080rgba(128, 0, 128, 0.502)#BF7FBF
Magenta#FF00FF80rgba(255, 0, 255, 0.502)#FF7FFF
Pink#FFC0CB80rgba(255, 192, 203, 0.502)#FFDFE5
Brown#A52A2A80rgba(165, 42, 42, 0.502)#D29494
White#FFFFFF80rgba(255, 255, 255, 0.502)#FFFFFF
Silver#C0C0C080rgba(192, 192, 192, 0.502)#DFDFDF
Grey#80808080rgba(128, 128, 128, 0.502)#BFBFBF
Black#00000080rgba(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