Convert any color between hex and RGB instantly. This free hex to RGB color converter works both directions with a live color preview, handy for web design and CSS work.
How the Hex to RGB Color Converter Works
This tool converts any 6-digit hex color code into its Red, Green, and Blue channel values, and works the reverse direction too — enter R, G, and B numbers and it builds the matching hex code, updating the live color swatch either way.
Formula: A 6-digit hex code is split into three 2-digit pairs (RRGGBB), and each pair is converted from base 16 to a base 10 number between 0 and 255 to get Red, Green, and Blue. In reverse, each RGB value (clamped between 0 and 255) is converted to a 2-digit base-16 string, zero-padded if needed, and the three pairs are joined into one 6-digit hex code.
- Hex code — a 6-digit hexadecimal color value entered in the Hex code field, with or without a leading #.
- R — the Red channel value, from 0 to 255, entered in the R field.
- G — the Green channel value, from 0 to 255, entered in the G field.
- B — the Blue channel value, from 0 to 255, entered in the B field.
Example Scenarios
| Hex Code | RGB Value |
|---|---|
| #000000 | rgb(0, 0, 0) |
| #FFFFFF | rgb(255, 255, 255) |
| #FF0000 | rgb(255, 0, 0) |
| #3E8C62 | rgb(62, 140, 98) |
| #1A2B3C | rgb(26, 43, 60) |
Hex to RGB Color Converter FAQ
Does this tool support 3-digit shorthand hex codes like #FFF?
No. This converter requires a full 6-digit hex code (for example #FFFFFF rather than #FFF). If you have a 3-digit shorthand code, expand it by duplicating each digit — #FFF becomes #FFFFFF — before entering it.What happens if I type a number above 255 into the R, G, or B field?
The converter automatically clamps any value below 0 up to 0, and any value above 255 down to 255, since 0-255 is the full valid range for a single RGB color channel. It won’t produce an invalid hex code from out-of-range input.What’s the exact math for turning a 6-digit hex code into RGB numbers?
Split the 6 characters into three pairs: the first two digits are Red, the middle two are Green, and the last two are Blue. Each pair is a base-16 (hexadecimal) number, so it’s converted to its base-10 equivalent — for instance hex “3E” equals decimal 62.Can I use this converter for CSS background-color values?
Yes. Enter your hex code or RGB values and copy either the resulting hex string or the rgb(r, g, b) format directly into a CSS background-color, color, or border-color property — both formats are valid CSS color syntax.Why does the color swatch update as I type?
The tool recalculates on every keystroke in the Hex, R, G, or B fields, so the swatch background color and the converted values in the other format stay in sync instantly without needing to click a separate calculate button.What’s the difference between hex and RGB color formats?
Hex represents a color as a single 6-digit base-16 string commonly used in CSS and design software, while RGB represents the same color as three separate base-10 numbers (0-255) for the red, green, and blue channels. Both describe identical colors, just in different notations.Related Calculators
Electronics hobbyists identifying component values may prefer the resistor color code calculator for reading resistor bands, while developers working with other numeral systems can use the binary to decimal converter for base conversions or the scientific calculator for general-purpose math.