HEX to RGB Converter
Convert HEX to RGB in real time. Type or paste a hex color code such as #4F46E5 and copy the rgb() value, plus RGBA, HSL and OKLCH for the same color.
Accepts 3, 4, 6 and 8-digit hex codes, with or without #. You can also paste rgb(), hsl() or oklch().
For Swift, Unity, GLSL and other code that expects channel values from 0 to 1.
| HEX | | |
|---|---|---|
| HEX + alpha | | |
| RGB | | |
| RGBA | | |
| HSL | | |
| OKLCH | | |
| Tailwind | |
Convert Hex Color Codes to RGB Online
Designers usually share colors as hex codes, while CSS, JavaScript, design APIs and many apps ask for RGB values. This HEX to RGB converter turns any hex code into the matching red, green and blue values the moment you type it.
It also shows the same color as RGBA, HSL, OKLCH, an 8-digit hex code, a Tailwind class and normalized 0–1 values for code. Everything runs in your browser, so it is instant and works offline once the page has loaded.
How to convert HEX to RGB
- Enter the hex code. Type or paste a value like
#4F46E5,4F46E5or the short form#FFFinto the HEX color code field. You can also pick a color with the color picker. - Read the RGB value. The result updates as you type, for example
rgb(79, 70, 229). - Copy what you need. Click Copy next to the RGB value, or next to any other format in the table: HEX with alpha, RGBA, HSL, OKLCH or the Tailwind class.
How HEX to RGB conversion works
A hex color code is three pairs of hexadecimal (base-16) digits: one pair each for red, green and blue. Each pair is a number from 00 to FF, which is 0 to 255 in decimal. To convert a pair, multiply the first digit by 16 and add the second digit, where A=10, B=11, C=12, D=13, E=14 and F=15.
| Channel | Hex pair | Calculation | Decimal |
|---|---|---|---|
| Red | 4F | 4 × 16 + 15 | 79 |
| Green | 46 | 4 × 16 + 6 | 70 |
| Blue | E5 | 14 × 16 + 5 | 229 |
So #4F46E5 is rgb(79, 70, 229). The converter does this for every pair, including the alpha pair of 8-digit codes.
3, 4, 6 and 8-digit hex codes
| Format | Example | Meaning | RGB result |
|---|---|---|---|
| #RGB | #FA0 | Shorthand: each digit is doubled (#FFAA00) | rgb(255, 170, 0) |
| #RRGGBB | #4F46E5 | Standard 6-digit code | rgb(79, 70, 229) |
| #RGBA | #4F48 | Shorthand with alpha (#44FF4488) | rgba(68, 255, 68, 0.533) |
| #RRGGBBAA | #4F46E580 | 6-digit code plus alpha (80 ≈ 50%) | rgba(79, 70, 229, 0.502) |
Common colors in HEX and RGB
| Color | HEX | RGB |
|---|---|---|
| White | #FFFFFF | rgb(255, 255, 255) |
| Black | #000000 | rgb(0, 0, 0) |
| Red | #FF0000 | rgb(255, 0, 0) |
| Lime (pure green) | #00FF00 | rgb(0, 255, 0) |
| Blue | #0000FF | rgb(0, 0, 255) |
| Yellow | #FFFF00 | rgb(255, 255, 0) |
| Orange | #FFA500 | rgb(255, 165, 0) |
| Purple | #800080 | rgb(128, 0, 128) |
| Gray | #808080 | rgb(128, 128, 128) |
| Indigo 600 (Tailwind CSS v3) | #4F46E5 | rgb(79, 70, 229) |
| Slate 900 (Tailwind CSS v3) | #0F172A | rgb(15, 23, 42) |
Using RGB values in CSS, Tailwind CSS and code
- CSS:
color: rgb(79, 70, 229);works everywhere. Modern browsers also accept the space syntaxrgb(79 70 229)andrgb(79 70 229 / 50%)for transparency. - Tailwind CSS: use an arbitrary value such as
bg-[#4F46E5]ortext-[rgb(79,70,229)], or add the color to your theme. See the Tailwind CSS color palette for ready-made shades. - JavaScript and canvas:
ctx.fillStyle = 'rgb(79, 70, 229)'. - Swift, Unity and shaders: these usually expect values from 0 to 1. Use the Normalized RGB field, for example
0.310, 0.275, 0.898.
Frequently Asked Questions
Common questions about converting hex color codes to RGB.
Split the 6-digit hex code into three pairs and convert each pair from base 16 to base 10. #4F46E5 becomes 4F = 79, 46 = 70 and E5 = 229, so the RGB value is rgb(79, 70, 229). The converter above does this instantly.
#FFFFFF is pure white, which is rgb(255, 255, 255). #000000 is black, rgb(0, 0, 0).
Yes. Short codes are expanded by doubling each digit, so #FFF becomes #FFFFFF and #FA0 becomes #FFAA00, which is rgb(255, 170, 0).
The last two digits are the alpha channel. #4F46E580 has an alpha of 80 in hex, which is 128 out of 255 or about 0.5, so it converts to rgba(79, 70, 229, 0.502).
No. 4F46E5 and #4F46E5 give the same result. Upper and lower case letters also work the same.
Both describe exactly the same colors and work in every browser. Hex is shorter; rgb() is easier to read and to add transparency to. Use whichever your team prefers.
Yes. Paste an rgb() value into the field above, or use the RGB to HEX converter.