How to use the rgba to hex converter
- Enter the Red, Green and Blue channel values as integers from 0 to 255.
- Set the Alpha value between 0 (fully transparent) and 1 (fully opaque). All four fields are required; an empty field shows an error instead of counting as 0.
- Read the 8-digit HEX result that includes the alpha channel.
- Copy the HEX6 code if you need the color without transparency, or grab the CSS
rgba()string.
How RGBA to HEX conversion works
The RGBA color model uses four channels: red, green, blue (each 0 to 255) and alpha (0 to 1). To convert rgba to hex, each channel is transformed into a two-character hexadecimal string.
For example, take R=66, G=133, B=244, A=0.8:
- Red: 66 in decimal is
42in hex. - Green: 133 in decimal is
85in hex. - Blue: 244 in decimal is
F4in hex. - Alpha: 0.8 multiplied by 255 gives 204, which is
CCin hex.
Concatenating these yields the 8-digit hex code #4285F4CC. The first six characters represent the color, and the last two represent the opacity.
Common RGBA to HEX values
This table shows frequently used colors converted from RGBA to 8-digit hex format.
| Color | RGBA | HEX8 | HEX6 |
|---|---|---|---|
| Black (opaque) | 0, 0, 0, 1 | #000000FF | #000000 |
| White (opaque) | 255, 255, 255, 1 | #FFFFFFFF | #FFFFFF |
| Red (opaque) | 255, 0, 0, 1 | #FF0000FF | #FF0000 |
| Green (opaque) | 0, 128, 0, 1 | #008000FF | #008000 |
| Blue (50% opacity) | 0, 0, 255, 0.5 | #0000FF80 | #0000FF |
| Black (80% opacity) | 0, 0, 0, 0.8 | #000000CC | #000000 |
When to use 8-digit hex vs rgba()
CSS supports both the rgba() function and 8-digit hex codes for colors with transparency. The rgba to 8 digit hex format (#RRGGBBAA) is part of the CSS Color Module Level 4 specification and is supported in all modern browsers.
Use 8-digit hex when you want compact notation, especially in design tokens, configuration files or utility classes where brevity matters. Use rgba() when you need to manipulate the alpha channel dynamically with CSS custom properties, since rgba(var(--r), var(--g), var(--b), var(--a)) is easier to parameterize than splitting a hex string.
If you need to go the other direction, the hex to rgba tool converts 8-digit hex back to individual channels.
Alpha channel rounding
The alpha channel in CSS ranges from 0 to 1, but hex uses an integer from 0 to 255. Converting requires multiplying the alpha by 255 and rounding to the nearest integer. For instance, an alpha of 0.5 becomes Math.round(0.5 * 255) = 128, which is 80 in hex.
Because 256 discrete steps cannot perfectly represent every decimal fraction, some round-trip conversions lose precision. An alpha of 0.33 converts to 84 in decimal (54 hex), but converting 54 back gives 84 / 255 = 0.3294..., not exactly 0.33. This is normal and visually imperceptible.
Worked examples
| Example | Input | Result |
|---|---|---|
| Semi-transparent blue | Red (R): 66; Green (G): 133; Blue (B): 244; Alpha (A): 0.8 | HEX8 (with alpha): #4285F4CC; HEX6 (no alpha): #4285F4; CSS rgba(): rgba(66, 133, 244, 0.8); Opacity: 80% |
| Fully opaque red | Red (R): 255; Green (G): 0; Blue (B): 0; Alpha (A): 1 | HEX8 (with alpha): #FF0000FF; HEX6 (no alpha): #FF0000; CSS rgba(): rgba(255, 0, 0, 1); Opacity: 100% |
| Half-transparent black | Red (R): 0; Green (G): 0; Blue (B): 0; Alpha (A): 0.5 | HEX8 (with alpha): #00000080; HEX6 (no alpha): #000000; CSS rgba(): rgba(0, 0, 0, 0.5); Opacity: 50% |
| Fully transparent white | Red (R): 255; Green (G): 255; Blue (B): 255; Alpha (A): 0 | HEX8 (with alpha): #FFFFFF00; HEX6 (no alpha): #FFFFFF; CSS rgba(): rgba(255, 255, 255, 0); Opacity: 0% |
FAQ
What is an 8-digit hex color?
An 8-digit hex color extends the standard 6-digit hex code by appending two characters for the alpha channel. The format is #RRGGBBAA, where AA represents opacity from 00 (fully transparent) to FF (fully opaque).
How do I convert rgba to hex with alpha?
Multiply the alpha value (0 to 1) by 255, round to the nearest integer, then convert that number to a two-digit hexadecimal string. Append it to the standard 6-digit hex color code.
Do all browsers support 8-digit hex colors?
Yes, all modern browsers including Chrome, Firefox, Safari and Edge support the #RRGGBBAA format. It was standardized in CSS Color Module Level 4.
Is there a difference between rgba to hex and rgb to hex?
The rgb to hex conversion produces a 6-digit code without transparency information. The rgba to hex conversion produces an 8-digit code that includes the alpha channel for opacity.
Why does my alpha value change slightly after converting back and forth?
Hex alpha uses 256 discrete steps (0 to 255), while CSS alpha uses continuous decimals from 0 to 1. Some fractional values cannot be represented exactly in 256 steps, causing minor rounding differences on round-trip conversion.
Can I use shorthand hex with alpha, like #RGBA?
Yes, CSS supports 4-digit shorthand hex codes where each character is doubled. For example, #F008 expands to #FF000088. However, 8-digit hex is more readable and commonly preferred.