Convert an RGBA color — red, green, blue, and alpha (transparency) — into its HEX equivalent instantly. Enter your values or paste a full rgba() string, and get the 6-digit HEX, the alpha-aware 8-digit HEX, and the alpha value expressed as both a HEX byte and a percentage.
Or set the values manually below.
Note: standard 6-digit HEX has no alpha channel, so transparency is dropped when you use it. The 8-digit HEX (RRGGBBAA) format keeps the alpha value and is supported in all modern browsers.
How to convert RGBA to HEX
To convert RGBA to HEX, convert each of the red, green, and blue values (0–255) to a two-digit hexadecimal number, then combine them into a single 6-character code prefixed with #.
The formula for each channel is:
HEX = Math.round(value).toString(16), padded to 2 digits
For example, rgba(255, 0, 0, 0.5) converts as follows:
- Red
255→FF - Green
0→00 - Blue
0→00 - Combined:
#FF0000
Note that this 6-digit result drops the alpha value — standard HEX has no way to represent transparency. If you need to preserve it, use 8-digit HEX instead (covered below).
Does HEX support transparency?
Standard 6-digit HEX does not support transparency — it only stores red, green, and blue. To represent transparency in HEX, you need the 8-digit HEX8 format (#RRGGBBAA), which appends a two-digit alpha channel to the end of a normal HEX code.
The alpha channel is calculated by multiplying the RGBA alpha value (0–1) by 255, then converting the result to a two-digit HEX byte:
Alpha HEX = Math.round(alpha × 255), converted to hex
So rgba(255, 0, 0, 0.5) becomes #FF000080 — the 80 at the end represents 50% opacity.
Browser support: 8-digit HEX (HEX8) is valid CSS and works in all current major browsers (Chrome, Firefox, Safari, Edge). It is not supported in Internet Explorer, so if you need to support IE, use rgba() directly instead.
Alpha to HEX reference table
| Opacity (%) | Alpha (0–1) | HEX byte |
|---|---|---|
| 100% | 1.00 | FF |
| 90% | 0.90 | E6 |
| 75% | 0.75 | BF |
| 50% | 0.50 | 80 |
| 25% | 0.25 | 40 |
| 10% | 0.10 | 1A |
| 0% | 0.00 | 00 |
Use this table as a quick lookup when hand-writing 8-digit HEX values without a converter.
Where this comes up in WordPress
If you’re setting custom colors in theme.json or the WordPress block editor’s color palette, opacity is usually set with an rgba() value in the color picker — but some contexts (custom CSS, third-party page builders, design tokens) expect a HEX string instead. Converting your RGBA value to 8-digit HEX lets you keep the same color and transparency when moving between the two formats, without picking a new opacity by eye.
FAQ
How do you convert RGBA to HEX?
Convert the red, green, and blue values to two-digit hexadecimal numbers and combine them into a 6-character code. If you need to keep the transparency, also convert the alpha value (0–1) to a hex byte by multiplying it by 255, and append it to get an 8-digit HEX8 code.
Can a HEX code have opacity or transparency?
Standard 6-digit HEX cannot represent opacity. The 8-digit HEX8 format (#RRGGBBAA) can, by adding a two-character alpha channel to the end of the code.
What is the HEX code for rgba(0,0,0,0.5)?rgba(0,0,0,0.5) converts to #000000 as 6-digit HEX (opacity dropped), or #00000080 as 8-digit HEX8 (opacity preserved).
Is 8-digit HEX (#RRGGBBAA) valid CSS?
Yes. 8-digit HEX is valid CSS and is supported in all current major browsers. It is not supported in Internet Explorer.
Does converting RGBA to HEX lose information?
Only if you use 6-digit HEX — the alpha value is dropped, since standard HEX has no alpha channel. Using 8-digit HEX8 instead preserves the alpha value exactly, with no loss beyond normal rounding to the nearest hex byte.
