RGB and HEX converter
Convert colours between RGB and HEX: #RGB, #RRGGBB, #RRGGBBAA, rgb()/rgba(), 0-255 and percentage channels, batch conversion line by line, HEX / rgb / percentage output, case and alpha control.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Accepts #RGB / #RRGGBB / #RRGGBBAA, rgb() / rgba(), with channels as 0-255 or percentages.
Result
Conversions follow CSS Color 4: percentage to byte is round(percent ÷ 100 × 255).
Enter a colour to see the result
What this tool does
- Turn the #RRGGBB from a design file into the rgb() / rgba() that CSS needs
- Normalise a whole colour list into one notation (HEX, rgb() or percentages) in one go
- Check colours with transparency and see whether #RRGGBBAA and rgba() really match
Example
Input
rgb(51, 102, 153)
Output
#336699
HEX is the default output. Switch the same colour to percentages to get rgb(20%, 40%, 60%); #33669980 equals rgba(51, 102, 153, 0.502).
Frequently asked questions
How are percentages and 0-255 values converted?
Per CSS Color 4 a byte is round(percent ÷ 100 × 255), so 50% maps to 128 and not 127; going the other way keeps one decimal by default, so 128 prints as 50.2%.
Why does an alpha of 0.5 become 80 and not 7F?
The 8-digit HEX alpha is a 0-255 byte: round(0.5 × 255) = 128 = 0x80. Reading it back, 0x80 = 128 ÷ 255 ≈ 0.502, printed with three decimals by default.
Which notations are accepted?
#RGB, #RGBA, #RRGGBB, #RRGGBBAA (the # is optional), rgb() / rgba(), space separated and slash syntax such as rgb(51 102 153 / 0.5); channels may be 0-255 or 0%-100%.
What happens if one line of a batch is invalid?
Only that line is affected: it is skipped in the output and the error panel lists its line number and error code (invalid-hex, invalid-hex-length, invalid-range, invalid-alpha and so on) while the other lines still convert.
Are HSL, HSV or colour names supported?
No. This tool only converts between RGB and HEX; HSL/HSV/CMYK and named colours live in other tools.
Keywords:rgbargb to hexcolor converter