Connect via MCP →

Enter Calculation

Enter a 3- or 6-digit hex code, with or without the leading #.

Formula

Advertisement

Results

RGB Color
rgb(52, 152, 219)
from #3498DB
Red (R) 52
Green (G) 152
Blue (B) 219
Normalized Hex #3498DB
CSS rgb(52, 152, 219)

What Is a Hex to RGB Converter?

A hex color code is a six-digit hexadecimal representation of a color, written as #RRGGBB. Each two-digit pair encodes one of the three additive color channels: red, green and blue. This converter reads a hex code and returns the equivalent RGB triplet, where each channel is an integer from 0 to 255. RGB is the format CSS, design software and most screens use under the hood, so converting between the two is a daily task for web developers and designers.

How to Use It

Type a hex code into the box — with or without the leading #. Both the full six-digit form (#3498DB) and the three-digit shorthand (#39C, which expands to #3399CC) are accepted. The tool cleans up any stray characters, normalizes the code, and instantly shows the red, green and blue values along with a live color swatch and ready-to-paste CSS.

The Formula Explained

Hexadecimal is base 16, using the digits 0–9 and letters A–F (where A=10 … F=15). A two-character pair is converted with the rule value = first digit \(\times\) 16 + second digit. So FF = \(15 \times 16 + 15 = 255\), the maximum, and 00 = 0, the minimum. The three pairs are decoded independently into R, G and B.

$$(R,\,G,\,B) = \bigl(\,\text{hex}_{[1,2]},\ \text{hex}_{[3,4]},\ \text{hex}_{[5,6]}\,\bigr)_{16}$$ $$\text{where}\quad \left\{ \begin{aligned} R &= \left(\text{Hex Code}\ \text{digits 1-2}\right)_{16} \\ G &= \left(\text{Hex Code}\ \text{digits 3-4}\right)_{16} \\ B &= \left(\text{Hex Code}\ \text{digits 5-6}\right)_{16} \end{aligned} \right.$$
Diagram showing a six-digit hex code split into three two-digit pairs mapped to red, green and blue values
A hex code splits into three pairs, each converted to a 0-255 channel value.

Worked Example

Take #3498DB. The red pair is 34 = \(3 \times 16 + 4 =\) 52. The green pair is 98 = \(9 \times 16 + 8 =\) 152. The blue pair is DB = \(13 \times 16 + 11 =\) 219. The result is rgb(52, 152, 219) — a popular flat-design blue.

Single hex color sample with its converted red, green and blue channel breakdown shown as three colored bars
A worked example: one hex code shown as a swatch beside its R, G, B channels.

FAQ

Does it accept shorthand hex like #FFF? Yes. A three-digit code is expanded by doubling each digit, so #FFF becomes #FFFFFF = rgb(255, 255, 255).

What about an alpha (transparency) channel? This tool handles the three-channel RGB color. An 8-digit hex with alpha is trimmed to its first six digits for the color conversion.

How do I go from RGB back to hex? Format each channel value as a two-digit hexadecimal number and concatenate them after a #. For example 52, 152, 219 → 34, 98, DB → #3498DB.

Last updated: