What Is Hex to RGB Conversion?
A hex color code is a 6-digit hexadecimal (base-16) representation of a color, commonly used in web design and CSS — for example #3498DB. Each pair of digits encodes one of the three primary color channels: red, green and blue. The RGB model expresses the same color as three decimal numbers between 0 and 255. This converter translates a hex code into its equivalent RGB triplet and shows a live color swatch.
How to Use It
Type or paste a hex color code into the box. You can include the leading # or leave it out — both work. The tool accepts standard 6-digit codes as well as 3-digit shorthand (e.g. #0AF, which expands to #00AAFF). Press calculate to see the red, green and blue values plus a preview swatch.
The Formula Explained
Conversion is a direct base-16 parse. The 6-character string is split into three 2-character pairs. Each pair is read as a hexadecimal number: the first hex digit is multiplied by 16, and the second is added. So a pair "FF" = \(15 \times 16 + 15 = 255\), and "00" = 0. The general formula is
$$\text{value} = (\text{first digit} \times 16) + \text{second digit}$$where each digit ranges 0–15 (A–F representing 10–15).
$$(R,G,B) = \big(\,\text{hex}_{[1,2]},\ \text{hex}_{[3,4]},\ \text{hex}_{[5,6]}\,\big)_{16}$$where
$$\left\{ \begin{aligned} R &= \operatorname{int}_{16}\!\left(\text{Hex}_{[1,2]}\right) \\ G &= \operatorname{int}_{16}\!\left(\text{Hex}_{[3,4]}\right) \\ B &= \operatorname{int}_{16}\!\left(\text{Hex}_{[5,6]}\right) \end{aligned} \right.$$
Worked Example
Take #3498DB. Split into 34, 98, DB.
The result is rgb(52, 152, 219) — a familiar sky blue.
FAQ
Does case matter? No. #abcdef and #ABCDEF produce the same RGB result.
What about 3-digit codes? A 3-digit hex like #F60 is shorthand where each digit is doubled, becoming #FF6600 before conversion.
Why are values capped at 255? Each channel uses two hex digits, and the maximum two-digit hex value, FF, equals 255 — giving 256 possible levels (0–255) per channel.