HEX to RGBA Converter
Convert hex color codes to rgba() values with alpha. Supports 8-digit hex. Free and private.
Independently verified for accuracy
Calculator by Toolsloft ↗Enter a hex code to convert
Convert a hex color to an rgba() value, including the alpha channel for transparency. It reads 6-digit and 8-digit hex, plus 3 and 4 digit shorthand, and reports the alpha as a 0 to 1 decimal. Paste a hex code and copy the rgba() result for CSS.
How this is calculated
The first three byte pairs become the red, green, and blue channels. When an eighth pair of digits is present it is the alpha byte, divided by 255 and rounded to two decimals; a hex value with no alpha byte is treated as fully opaque.
How to use
- Enter a hex color code, for example #3366cc or #3366cc80.
- The rgba() result appears below as you type.
- Copy the rgba() value into your CSS.
Examples
- #3366cc:
rgba(51, 102, 204, 1) - #3366cc80:
rgba(51, 102, 204, 0.5)
FAQ
- How is the alpha value calculated?
- The last two hex digits are read as a byte from 0 to 255, then divided by 255 to give a 0 to 1 alpha. So 80 becomes 0.5 and ff becomes 1.
- What if my hex has no alpha?
- A 3 or 6 digit hex has no alpha byte, so the color is treated as fully opaque and the alpha is reported as 1.