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
HTML 3.2 specified hexadecimal RGB values for several color-related attributes. That documents HTML support, but doesn't establish that the notation originated then. The format is case-insensitive (#3b82f6 = #3B82F6) and supports shorthand when each channel uses identical hex digits (#FFF = #FFFFFF). Six-digit #RRGGBB represents opaque RGB, while CSS also supports four-digit #RGBA and eight-digit #RRGGBBAA forms when you need an alpha channel.
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 three-digit shorthand (#FFF for #FFFFFF) doubles each RGB digit, and CSS also supports four-digit #RGBA shorthand plus six- and eight-digit full forms. The eight-digit form (#3B82F6CC) adds the alpha byte, while the four-digit form provides the same channels in shorthand.
More Color scenarios
Related guides
Frequently asked questions
Is #FFF the same as #FFFFFF?
How do I convert a hex color like #3B82F6 to RGB values?
What's the difference between #RGB and #RRGGBB hex notation?
Related tools
Contrast Checker
Check color contrast ratios for WCAG AA/AAA accessibility compliance.
Use tool ➜JSON Formatter
Validate, format, and minify JSON data with readable output and error detection.
Use tool ➜Aspect Ratio Visualizer
Visually compare width differences between 16:9, 21:9, and 32:9 monitors.
Use tool ➜