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().

RGB value

Normalized RGB (0–1)

For Swift, Unity, GLSL and other code that expects channel values from 0 to 1.

All color formats
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.

Hex color code converted to an RGB value#4F46E5rgb(79, 70, 229)HEX to RGBConverter

How to convert HEX to RGB

  1. Enter the hex code. Type or paste a value like #4F46E5, 4F46E5 or the short form #FFF into the HEX color code field. You can also pick a color with the color picker.
  2. Read the RGB value. The result updates as you type, for example rgb(79, 70, 229).
  3. 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.

ChannelHex pairCalculationDecimal
Red4F4 × 16 + 1579
Green464 × 16 + 670
BlueE514 × 16 + 5229

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

FormatExampleMeaningRGB result
#RGB#FA0Shorthand: each digit is doubled (#FFAA00)rgb(255, 170, 0)
#RRGGBB#4F46E5Standard 6-digit codergb(79, 70, 229)
#RGBA#4F48Shorthand with alpha (#44FF4488)rgba(68, 255, 68, 0.533)
#RRGGBBAA#4F46E5806-digit code plus alpha (80 ≈ 50%)rgba(79, 70, 229, 0.502)

Common colors in HEX and RGB

ColorHEXRGB
White#FFFFFFrgb(255, 255, 255)
Black#000000rgb(0, 0, 0)
Red#FF0000rgb(255, 0, 0)
Lime (pure green)#00FF00rgb(0, 255, 0)
Blue#0000FFrgb(0, 0, 255)
Yellow#FFFF00rgb(255, 255, 0)
Orange#FFA500rgb(255, 165, 0)
Purple#800080rgb(128, 0, 128)
Gray#808080rgb(128, 128, 128)
Indigo 600 (Tailwind CSS v3)#4F46E5rgb(79, 70, 229)
Slate 900 (Tailwind CSS v3)#0F172Argb(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 syntax rgb(79 70 229) and rgb(79 70 229 / 50%) for transparency.
  • Tailwind CSS: use an arbitrary value such as bg-[#4F46E5] or text-[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.