Hex to CSS rgba() String Converter

Turn a hex color plus opacity into a ready-to-paste CSS rgba() function string.

Ad placeholder (leaderboard)

Turn a hex color into a CSS rgba() string

The Hex to CSS rgba() String Converter takes a hex color and an opacity and produces a copy-ready CSS color string. It outputs the classic comma-separated rgba() form, a plain rgb() form, and the modern CSS Color 4 slash-alpha syntax, with a live swatch over a transparency checkerboard so you can judge the alpha at a glance.

How it works

A hex color packs three 8-bit channels into base 16. The converter splits the string into pairs and parses each pair as a 0–255 value:

#3366ff -> r = 0x33 = 51, g = 0x66 = 102, b = 0xff = 255

Shorthand 3-digit and 4-digit hex are expanded by doubling each digit (#36f becomes #3366ff). If the hex carries an eighth-digit alpha byte, that byte is divided by 255 to get a base alpha. The opacity percentage you enter is converted to a 0–1 fraction and multiplied with the base alpha, producing the final alpha channel used in the rgba() string.

Example

Entering #3366ff at 80 percent opacity yields rgba(51, 102, 255, 0.8). The equivalent CSS Color 4 form is rgb(51 102 255 / 80%). If you instead enter #3366ff80 at 50 percent, the built-in alpha of about 0.5 is multiplied by 0.5 to give roughly 0.25.

Notes

For maximum browser support the comma rgba() form is the safest choice; the space-and-slash form is cleaner but newer. Alpha is rounded to three decimal places and trailing zeros are trimmed so the output stays tidy.

Ad placeholder (rectangle)