RGBA to HEX Converter

Convert RGBA values to 6-digit or 8-digit HEX for CSS. Use the sliders or paste an rgba() string to preserve opacity in a compact color code.

HEX Result
#1E90FF

When 8-Digit HEX Helps

Eight-digit HEX is compact for design tokens and CSS variables because opacity travels with the color. Use 6-digit HEX for fully opaque colors and 8-digit HEX when the alpha channel matters.

RGBA to HEX Examples

RGBA HEX Result
rgba(0, 0, 0, 0.5) #00000080 50% black overlay
rgba(30, 144, 255, 1) #1E90FF Opaque blue
rgba(255, 255, 255, 0.8) #FFFFFFCC Soft surface

How the Conversion Works

HEX stores the alpha channel as a hexadecimal byte. An alpha value of 0.5 becomes 128 in decimal, then 80 in HEX. Fully opaque colors stay as 6-digit HEX.

Frequently Asked Questions

When does HEX need 8 digits?

Use 8-digit HEX when you need transparency. The last two digits represent alpha.

Does the tool preserve opacity?

Yes. If alpha is 1, the tool returns 6-digit HEX. Otherwise it returns 8-digit HEX with alpha.

What happens if RGB values are outside 0-255?

Channel values are clamped to the valid 0-255 range before conversion, matching how RGB bytes are stored.

Related Color Tools

Open the next tool for this color task.