My Tool Studio
Color

HEX to RGB Converter

This hex to rgb converter turns any HEX color code into its RGB value the moment you paste it. It reads 3, 4, 6 and 8 digit codes, with or without the #, and when the hex carries an alpha channel you get an rgba() value ready for CSS. The result card also lists the channels as 0 to 255 numbers, 0 to 1 decimals and percentages. Below it, the page walks through the math for your exact code, gives ready snippets for CSS, Swift, Android, Flutter and Unity, and converts a whole list of hex codes at once with a CSV download. Front-end developers use it when a brand guide gives #E4572E and the stylesheet needs a semi-transparent overlay. HSL, HSV, CMYK, OKLCH, LAB and more are shown too.

Always freeNo sign upRuns in your browser
Result (RGB)
rgb(99, 102, 241)
Channels 0 to 25599, 102, 241
Decimals 0 to 10.388, 0.4, 0.945
Percentrgb(38.8% 40% 94.5%)
Modern CSSrgb(99 102 241)
rgbrgb(99, 102, 241)
hex#6366F1
hslhsl(239, 84%, 67%)
hsvhsv(239, 59%, 95%)
cmykcmyk(59%, 58%, 0%, 5%)
oklchoklch(58.54% 0.2041 277.12)

How this conversion is calculated

  1. Split the hex code into pairs: 63 66 F1.
  2. Convert each pair from base 16: 63 = 6 x 16 + 3 = 99.
  3. 66 = 6 x 16 + 6 = 102. F1 = 15 x 16 + 1 = 241.
  4. Result: rgb(99, 102, 241).

Code snippets

CSScolor: #6366F1;
CSS variable--brand: #6366F1;
SCSS$brand: #6366F1;
Swift (UIKit)UIColor(red: 0.388, green: 0.4, blue: 0.945, alpha: 1)
SwiftUIColor(red: 0.388, green: 0.4, blue: 0.945, opacity: 1)
Android XML<color name="brand">#6366F1</color>
Kotlin / Jetpack ComposeColor(0xFF6366F1)
Java (Android)Color.argb(255, 99, 102, 241)
FlutterColor(0xFF6366F1)
Unity C#new Color32(99, 102, 241, 255)
.NET C#Color.FromArgb(255, 99, 102, 241)
Python tuple(99, 102, 241)

Convert a list

Paste up to 1,000 values, one per line. Each line is converted to RGB.

More color formats (HWB, LAB, LCH, OKLab, XYZ and more)
RGB %rgb(38.8%, 40%, 94.5%)
HWBhwb(239 38.8% 5.5%)
OKLaboklab(58.54% 0.0253 -0.2025)
CIE LABlab(50.1% 38.69 -70.49)
CIE LCHlch(50.1% 80.4 298.76)
CIE LUV50.1, -8.88, -111.2
CIE XYZ25.769, 18.504, 85.416
CIE xyY0.1987, 0.1427, 18.504
Decimal6514417
Binary01100011 01100110 11110001
Nearest web safe#6666FF
Common colors reference table

Click a name to load it into the converter.

ColorHEXRGBHSL
#000000rgb(0, 0, 0)hsl(0, 0%, 0%)
#FFFFFFrgb(255, 255, 255)hsl(0, 0%, 100%)
#FF0000rgb(255, 0, 0)hsl(0, 100%, 50%)
#00FF00rgb(0, 255, 0)hsl(120, 100%, 50%)
#0000FFrgb(0, 0, 255)hsl(240, 100%, 50%)
#FFFF00rgb(255, 255, 0)hsl(60, 100%, 50%)
#00FFFFrgb(0, 255, 255)hsl(180, 100%, 50%)
#FF00FFrgb(255, 0, 255)hsl(300, 100%, 50%)
#C0C0C0rgb(192, 192, 192)hsl(0, 0%, 75%)
#808080rgb(128, 128, 128)hsl(0, 0%, 50%)
#800000rgb(128, 0, 0)hsl(0, 100%, 25%)
#808000rgb(128, 128, 0)hsl(60, 100%, 25%)
#008000rgb(0, 128, 0)hsl(120, 100%, 25%)
#800080rgb(128, 0, 128)hsl(300, 100%, 25%)
#008080rgb(0, 128, 128)hsl(180, 100%, 25%)
#000080rgb(0, 0, 128)hsl(240, 100%, 25%)
#FFA500rgb(255, 165, 0)hsl(39, 100%, 50%)
#FF6347rgb(255, 99, 71)hsl(9, 100%, 64%)
#FFD700rgb(255, 215, 0)hsl(51, 100%, 50%)
#4B0082rgb(75, 0, 130)hsl(275, 100%, 25%)

How to use

01

Paste or pick a hex code

Type a code such as #E4572E into Input (HEX), or use the color picker next to it. Shorthand like #F80 and 8 digit codes like #E4572ED9 are accepted, with or without the #.

02

Read the RGB result

The highlighted Result (RGB) card shows rgb() or, for codes with alpha, rgba(). Under it are the channels as 0 to 255, as 0 to 1 decimals, as percentages and in modern space syntax.

03

Copy the format you need

Press Copy on the result or on any variant. The grid below also lists HEX, HSL, HSV, CMYK and OKLCH. Use Switch to RGB to HEX to convert in the other direction.

Why HEX to RGB Converter

Hex to RGB formula with a worked example

A hex color is three base 16 numbers written side by side. Each pair runs from 00 (0) to FF (255). To convert a pair, multiply the first digit by 16 and add the second. Letters count as numbers: A is 10, B is 11, C is 12, D is 13, E is 14 and F is 15.

Take #6366F1. The red pair 63 is 6 x 16 + 3 = 99. The green pair 66 is 6 x 16 + 6 = 102. The blue pair F1 is 15 x 16 + 1 = 241. So #6366F1 is rgb(99, 102, 241). As decimals from 0 to 1 that is 0.388, 0.4 and 0.945, which you get by dividing each value by 255.

For an 8 digit code, the fourth pair is alpha. Divide it by 255 to get the opacity used in rgba(). For example, 80 is 128, and 128 divided by 255 is about 0.5.

Common colors in HEX and RGB

These are the 16 basic CSS colors plus orange, with their exact HEX and RGB values. They are handy for quick checks and for spotting when a code has been mistyped. Note that 80 in hex is 128, just over half of 255.

NameHEXRGB
Black#000000rgb(0, 0, 0)
White#FFFFFFrgb(255, 255, 255)
Red#FF0000rgb(255, 0, 0)
Lime#00FF00rgb(0, 255, 0)
Blue#0000FFrgb(0, 0, 255)
Yellow#FFFF00rgb(255, 255, 0)
Aqua (cyan)#00FFFFrgb(0, 255, 255)
Fuchsia (magenta)#FF00FFrgb(255, 0, 255)
Silver#C0C0C0rgb(192, 192, 192)
Gray#808080rgb(128, 128, 128)
Maroon#800000rgb(128, 0, 0)
Olive#808000rgb(128, 128, 0)
Green#008000rgb(0, 128, 0)
Purple#800080rgb(128, 0, 128)
Teal#008080rgb(0, 128, 128)
Navy#000080rgb(0, 0, 128)
Orange#FFA500rgb(255, 165, 0)

Common questions

How do I convert hex to RGB manually?
Split the six digits into three pairs and convert each pair from base 16 to base 10. For a pair, multiply the first digit by 16 and add the second, where A to F mean 10 to 15. #E4572E becomes E4 = 228, 57 = 87 and 2E = 46, so rgb(228, 87, 46).
How do I convert a hex code to RGBA?
If your hex has 8 digits, the last pair is the alpha, and the converter shows rgba() automatically. #E4572ED9 gives rgba(228, 87, 46, 0.85) because D9 is 217 and 217 divided by 255 is about 0.85. For a 6 digit hex, add the alpha yourself, for example rgba(228, 87, 46, 0.5).
What does an 8 digit hex color code mean?
It is #RRGGBBAA: red, green and blue plus an alpha (opacity) pair at the end. 00 is fully transparent and FF is fully opaque. All current browsers accept 8 digit hex in CSS.
Is a hex color code the same as RGB?
It is the same color written in a different number system. HEX writes each of the red, green and blue values as two base 16 digits, while rgb() writes them as decimal numbers from 0 to 255. Converting between them loses nothing.
What is #FFFFFF in RGB?
#FFFFFF is rgb(255, 255, 255), which is white. #000000 is rgb(0, 0, 0), black. Each FF pair is the maximum value of 255.
How does a 3 digit hex code like #F80 convert to RGB?
Each digit is doubled, so #F80 means #FF8800, which is rgb(255, 136, 0). A 4 digit code such as #F80C works the same way, with the last digit as alpha.
Why does the HEX to RGB converter show an error for my code?
The code has the wrong number of digits or a character outside 0 to 9 and A to F. Valid lengths are 3, 4, 6 or 8 digits. A common cause is copying a code with a trailing space or a missing digit, such as #12345.
When do I need RGB values as 0 to 1 decimals?
WebGL shaders, Unity, Swift's UIColor and many graphics libraries expect each channel as a decimal between 0 and 1. The Decimals 0 to 1 row gives those values, rounded to three places, ready to paste.
Does the hex to RGB conversion happen in my browser?
Yes. The page converts the code with JavaScript on your device and sends nothing to a server. It keeps working if you lose your connection after the page has loaded.
Can I convert a list of hex codes to RGB at once?
Yes. Paste the codes into Convert a list, one per line. Each line gets its RGB value, bad lines are flagged, and you can copy all results or download them as a CSV file. Up to 1,000 lines are converted in your browser.

More Color tools

View all