How to convert hex to RGB: the web developer's color format explained
Hex is the right format for opaque colors in web development. It's shorter than rgb(), universally recognized, and copy-pastes cleanly between Figma, VS Code, and browser DevTools. Use the 8-digit variant or rgba() when you need transparency.
Hex color codes like #3B82F6 are just RGB values written in hexadecimal. The first two characters are red (3B = 59), the middle two are green (82 = 130), and the last two are blue (F6 = 246). Hex is the dominant color format on the web because it's compact, universally supported, and easy to copy-paste between design tools and code.
By TechCompare · Updated
How this is calculated
Hex colors originated in HTML 3.2 and haven't changed since. The format is case-insensitive (#3b82f6 = #3B82F6) and supports shorthand when each channel uses identical hex digits (#FFF = #FFFFFF). The main limitation of hex is that it doesn't support an alpha channel. For transparency, you need the 8-digit hex format (#3B82F6CC) which adds RGBA support, or you switch to the rgba() functional notation in CSS.
Verdict
The format maps two hex characters per channel directly to the 0-255 integer per RGB channel: 3B becomes 59, 82 becomes 130, F6 becomes 246, summing to rgb(59, 130, 246). That 1:1 byte-per-channel structure is why hex survives every design tool round-trip losslessly, where rgb() risks being reformatted or the comma syntax gets mangled. The 3-digit shorthand (#FFF for #FFFFFF) only fires when each channel's two digits are identical, so #F8F8F8 collapses but most real brand colors don't. The 8-digit extension (#3B82F6CC) brings the alpha byte that the original HTML 3.2 spec couldn't express, and CSS Color Level 4+ accepts it natively alongside rgba().
