What is a Hex to RGB Converter?
A hex color code is a six-digit hexadecimal representation of a color used widely in web design, CSS, and digital graphics. It encodes the intensity of three color channels — red, green, and blue — using base-16 digits (0–9 and A–F). This converter takes a hex code such as #3498DB and translates it into the equivalent RGB triplet that many design tools, programming languages, and image editors expect.
How to Use It
Enter your hex color code in the field above. You can include the leading # or leave it out — both work. Standard six-digit codes (#RRGGBB) and three-digit shorthand (#RGB) are both supported; shorthand is automatically expanded (e.g. #0AF becomes #00AAFF). The result shows the full rgb(r, g, b) string, individual channel values, and a live color swatch.
The Formula Explained
Each color channel occupies two hexadecimal digits. The first two characters represent red, the middle two represent green, and the last two represent blue. Each pair is converted from base 16 to base 10:
$$(R,\,G,\,B) = \bigl(\text{hex}_{[1\text{-}2]},\ \text{hex}_{[3\text{-}4]},\ \text{hex}_{[5\text{-}6]}\bigr)_{16}$$\(R = \text{Int}_{16}\!\left(\text{Hex}[1\text{-}2]\right)\), \(G = \text{Int}_{16}\!\left(\text{Hex}[3\text{-}4]\right)\), \(B = \text{Int}_{16}\!\left(\text{Hex}[5\text{-}6]\right)\). Each channel ranges from \(0\) (00) to \(255\) (FF).
Worked Example
Take #3498DB. The red pair is 34, which equals \(3\times16 + 4 = \mathbf{52}\). The green pair is 98, equal to \(9\times16 + 8 = \mathbf{152}\). The blue pair is DB, where D = 13 and B = 11, giving \(13\times16 + 11 = \mathbf{219}\). So #3498DB = rgb(52, 152, 219).
FAQ
What does FFFFFF convert to? Pure white: rgb(255, 255, 255). And 000000 is pure black: rgb(0, 0, 0).
Can I enter a 3-digit code? Yes. Three-digit shorthand is doubled per digit — #F00 expands to #FF0000 = rgb(255, 0, 0).
Is the # required? No. The converter strips any leading # automatically, so both #1A2B3C and 1A2B3C work.