๐จ Hex to RGB Converter
By Shihab Mia ยท Updated 2026-07-10
Red
59
Green
130
Blue
246
Alpha
1
rgb(59, 130, 246) rgba(59, 130, 246, 1) hsl(217, 91%, 60%) A hex to RGB converter turns a hex code like #3B82F6 into rgb(59, 130, 246) by reading each two-digit pair as a base-16 number: 3B is 59, 82 is 130, and F6 is 246. This tool parses full #RRGGBB codes, expands #RGB shorthand such as #abc into #aabbcc, accepts upper or lower case with or without the hash, and also returns the matching rgba() and HSL values. Everything runs in your browser, so nothing is uploaded and results appear the instant you type.
What is the Hex to RGB Converter?
Hex and RGB are two ways of writing the same color. RGB describes a color as three channels, red, green, and blue, each from 0 to 255. A hex code packs those same three numbers into six hexadecimal digits, two per channel, because base-16 needs exactly two digits to cover the range 0 to 255 (00 to FF). A hex to RGB converter simply reverses that packing: it splits the six digits into three pairs and reads each pair as a number from 0 to 255.
The conversion is exact and lossless in both directions, so #3B82F6 and rgb(59, 130, 246) are the same pixel color, just written differently. Designers tend to copy hex from tools like Figma or a brand style guide, while CSS, canvas, and many charting libraries expect rgb() or rgba() when you need transparency. That gap is why a fast hex to RGB converter is one of the most-used utilities in a front-end workflow: you paste the hex your design gives you and get the rgb() string your code wants.
This hex to RGB converter also handles the two things people trip over. First, #RGB shorthand: a three-digit code like #abc is expanded by doubling each digit to #aabbcc before parsing, so #abc becomes rgb(170, 187, 204), not a broken value. Second, case and the hash symbol are optional, so 3b82f6, #3B82F6, and 3B82F6 all resolve to the same RGB triple. Anything that is not 3 or 6 valid hex digits is rejected with a friendly message instead of a silent wrong answer.
Beyond RGB, the tool converts the same color to HSL (hue, saturation, lightness), which is often easier to reason about when you want a lighter or more muted variant. For #3B82F6 that is hsl(217, 91%, 60%): a blue hue at 217 degrees, high saturation, medium lightness. Having hex, RGB, RGBA, and HSL side by side lets you copy whichever format the current file needs without hunting through a separate hex to RGB converter for each one.
When to use it
- Turning a brand hex code from a style guide into the rgb() value your CSS or design token file expects.
- Building an rgba() color so you can add transparency (for example a 20 percent overlay) that plain hex cannot express in older code.
- Feeding exact 0 to 255 channel values into a canvas, SVG, or charting library that takes numeric RGB rather than a hex string.
- Checking that a shorthand code like #abc expands correctly to #aabbcc = rgb(170, 187, 204) before you commit it.
How to use the Hex to RGB Converter
- Type or paste your hex color into the input. You can include the hash or not, use upper or lower case, and use #RGB shorthand or full #RRGGBB.
- Read the parsed Red, Green, and Blue values (0 to 255) and check the live swatch matches the color you expected.
- Copy the rgb(), rgba(), or hsl() string you need with the Copy button next to each one.
- Adjust the color with the built-in picker if you want to nudge it, then copy the updated values.
Formula & method
Worked examples
Convert the full hex code #3B82F6 (a common blue) to RGB.
- Remove the hash and split into pairs: 3B, 82, F6.
- Red: 3B in hex = 3x16 + 11 = 48 + 11 = 59.
- Green: 82 in hex = 8x16 + 2 = 128 + 2 = 130.
- Blue: F6 in hex = 15x16 + 6 = 240 + 6 = 246.
Result: rgb(59, 130, 246), or rgba(59, 130, 246, 1) with full opacity.
Convert the shorthand hex code #abc to RGB.
- It has 3 digits, so expand each by doubling: a a, b b, c c gives #aabbcc.
- Red: aa in hex = 10x16 + 10 = 170.
- Green: bb in hex = 11x16 + 11 = 187.
- Blue: cc in hex = 12x16 + 12 = 204.
Result: rgb(170, 187, 204), a soft blue-grey.
Common hex codes and their RGB values
| Hex | RGB | Color |
|---|---|---|
| #000000 | rgb(0, 0, 0) | Black |
| #FFFFFF | rgb(255, 255, 255) | White |
| #FF0000 | rgb(255, 0, 0) | Red |
| #00FF00 | rgb(0, 255, 0) | Green |
| #0000FF | rgb(0, 0, 255) | Blue |
| #3B82F6 | rgb(59, 130, 246) | Blue 500 |
| #808080 | rgb(128, 128, 128) | Grey |
Single hex digit to decimal value
| Hex digit | Decimal | Hex digit | Decimal |
|---|---|---|---|
| 0 | 0 | 8 | 8 |
| 1 | 1 | 9 | 9 |
| 2 | 2 | A | 10 |
| 3 | 3 | B | 11 |
| 4 | 4 | C | 12 |
| 5 | 5 | D | 13 |
| 6 | 6 | E | 14 |
| 7 | 7 | F | 15 |
Common mistakes to avoid
- Reading each hex pair as base 10. F6 is not 76 in the usual sense. Each pair is base 16, so F6 = 15x16 + 6 = 246. A good hex to RGB converter does this base conversion for you so you never have to do the arithmetic by hand.
- Not expanding #RGB shorthand. Shorthand like #abc means #aabbcc, not #ab0c00 or #0a0b0c. Each of the three digits is doubled before parsing, so #abc is rgb(170, 187, 204).
- Assuming hex can carry transparency. A 6-digit hex code only holds red, green, and blue. To add opacity you either use an 8-digit hex (RRGGBBAA) or convert to rgba(), for example rgba(59, 130, 246, 0.5) for 50 percent.
- Confusing hex order with RGB order. Hex is written RRGGBB, the same channel order as rgb(), so the first pair is always red. Do not reverse it. #FF8800 is rgb(255, 136, 0), an orange, not rgb(0, 136, 255).
Glossary
- Hex color code
- A color written as # followed by 3 or 6 hexadecimal digits, where each channel uses two digits from 00 to FF.
- RGB
- A color model that mixes Red, Green, and Blue light, each on a 0 to 255 scale, written as rgb(r, g, b).
- RGBA
- RGB plus an Alpha channel for opacity, from 0 (transparent) to 1 (opaque), written as rgba(r, g, b, a).
- HSL
- Hue (0 to 360 degrees), Saturation, and Lightness (both percentages). A more intuitive way to lighten or desaturate a color.
- Hexadecimal
- A base-16 number system using digits 0 to 9 and letters A to F, where A is 10 and F is 15.
- #RGB shorthand
- A 3-digit hex code where each digit is doubled to make the full 6-digit code, so #f0c becomes #ff00cc.
Frequently asked questions
How do I convert a hex color to RGB?
Split the 6-digit hex into three pairs and read each pair as a base-16 number from 0 to 255. For #3B82F6, 3B is 59, 82 is 130, and F6 is 246, giving rgb(59, 130, 246). This converter does the math instantly when you paste the code.
What is #3B82F6 in RGB?
#3B82F6 is rgb(59, 130, 246), a medium blue. As rgba it is rgba(59, 130, 246, 1) and as HSL it is hsl(217, 91%, 60%).
Does this hex to RGB converter accept shorthand like #abc?
Yes. Three-digit shorthand is expanded by doubling each digit before parsing, so #abc becomes #aabbcc, which is rgb(170, 187, 204). You can also drop the hash and use any case.
How do I add transparency when converting hex to RGB?
Convert to rgba() and set the alpha value yourself. This tool outputs rgba(r, g, b, 1) at full opacity; change the last number to something like 0.5 for 50 percent transparency, since a plain 6-digit hex code cannot store opacity.
Is hex to RGB conversion exact or does it lose color?
It is exact and fully reversible. Hex and RGB store the same three 0 to 255 channels, so #3B82F6 and rgb(59, 130, 246) are identical pixels with no rounding or color loss.
Why does my hex code show an error?
A valid hex code has exactly 3 or 6 hexadecimal digits (0 to 9 and A to F). Codes with the wrong length, or characters like G to Z, are rejected. Check for typos or extra spaces and the converter will parse it.