About the HEX to RGB
A HEX code such as #f25f1e and an rgb() value describe the same colour in different notations. This tool converts HEX to RGB, handling 3, 4, 6 and 8-digit codes; an 8 or 4-digit code with an alpha channel produces an rgba() value. Convert several at once, one per line.
The arithmetic is a base change. Each pair of hex digits is a base-16 number from 00 to ff, which is 0 to 255 in decimal, so 1f becomes 31 and c1 becomes 193. Shorthand is expanded by doubling each digit rather than by padding with a zero, so #1fc means #11ffcc and not #01f0c0. Getting that rule wrong is the most common hand-conversion mistake and it shifts every channel at once.
The alpha byte is the other trap. In an 8-digit code the last pair is still 0 to 255, but CSS rgba() expects a 0 to 1 decimal, so 80 becomes 0.502 rather than 80. The division is done for you here. A typical use is lifting a palette out of a brand guide that lists only HEX and rewriting it as rgb(), so a component can set its own opacity without a second variable being invented for every tint.
RGB is often preferred in CSS when you want to adjust opacity or interpolate colours. To convert back, use RGB to HEX; to see every format at once, the Color Converter. If the alpha form is what you actually want, HEX to RGBA goes straight there.
How to use
- Paste HEX codes, one per line.
- Copy the rgb() values.
- An alpha channel gives rgba().
Common questions
- Does it handle #RGB shorthand?
- Yes, 3 and 4-digit shorthand is expanded, so #1fc becomes rgb(17, 255, 204).
- What about an alpha channel?
- An 8-digit (#RRGGBBAA) or 4-digit code produces an rgba() value with the alpha as a 0-1 decimal.
- Is the # required?
- No, it is optional.