EasyUnitConverter.com

HEX to RGB Color Converter

Enter the hex color code to convert to RGB or RGB to Hex.

#FF5733

What does this Hex to RGB converter do?

It takes a hexadecimal color code (like #FF5733) and converts it to its RGB equivalent β€” three separate values for Red, Green, and Blue channels, each ranging from 0 to 255. This is useful when you need to use a hex color in software that requires RGB input, or when you want to understand the color composition.

How to Convert Hex to RGB

  1. Get the 2 left digits of the hex color code and convert to decimal β€” this is the Red value
  2. Get the 2 middle digits and convert to decimal β€” this is the Green value
  3. Get the 2 right digits and convert to decimal β€” this is the Blue value

Formula

R = parseInt(hex[0..1], 16)

G = parseInt(hex[2..3], 16)

B = parseInt(hex[4..5], 16)

Example

Hex: #FF5733

R = FF₁₆ = 15Γ—16 + 15 = 255

G = 57₁₆ = 5Γ—16 + 7 = 87

B = 33₁₆ = 3Γ—16 + 3 = 51

Result: rgb(255, 87, 51)

Hex to RGB Color Table

ColorHexRGBPreview
Black#000000000
White#FFFFFF255255255
Red#FF000025500
Lime#00FF0002550
Blue#0000FF00255
Yellow#FFFF002552550
Cyan#00FFFF0255255
Magenta#FF00FF2550255
Orange#FFA5002551650
Coral#FF7F5025512780
Tomato#FF63472559971
Gold#FFD7002552150
Silver#C0C0C0192192192
Gray#808080128128128
Maroon#80000012800
Navy#00008000128

Technical Details

Hex color codes use 24-bit color (8 bits per channel). The format is #RRGGBB where each pair represents a value from 00 to FF (0-255 in decimal). CSS also supports shorthand #RGB notation where each digit is doubled (#F00 = #FF0000). Modern CSS additionally supports rgba() for transparency and hsl() for hue-saturation-lightness color models.

Frequently Asked Questions

How do I convert a hex color code to RGB?

Split the 6-digit hex code into three pairs (RR, GG, BB) and convert each pair from hexadecimal to decimal. For example, #FF5733 becomes R=255, G=87, B=51.

What is the difference between hex and RGB color formats?

Both represent the same colors. Hex uses a compact 6-character string (#FF5733), while RGB uses three decimal numbers (255, 87, 51). Hex is common in CSS and design tools; RGB is used in programming and image editing.

What does #000000 mean in RGB?

#000000 is black β€” all three channels (red, green, blue) are at zero. Conversely, #FFFFFF is white with all channels at maximum (255, 255, 255).

Can I use shorthand hex codes like #F00?

Yes. In CSS, 3-digit hex codes are expanded by doubling each digit. So #F00 becomes #FF0000 (pure red), and #09C becomes #0099CC.

Why do designers use hex colors instead of RGB?

Hex codes are shorter to type in CSS and easier to copy/paste. They also make it simple to identify color relationships β€” similar hex values produce similar colors.

Solved Examples β€” Hex to RGB Conversions

Example 1: Convert #4CAF50 (Material Design Green) to RGB

Solution:

Split into pairs: 4C, AF, 50

R = 4C₁₆ = 4Γ—16 + 12 = 76

G = AF₁₆ = 10Γ—16 + 15 = 175

B = 50₁₆ = 5Γ—16 + 0 = 80

Answer: rgb(76, 175, 80)

Example 2: Convert #1E90FF (Dodger Blue) to RGB

Solution:

Split into pairs: 1E, 90, FF

R = 1E₁₆ = 1Γ—16 + 14 = 30

G = 90₁₆ = 9Γ—16 + 0 = 144

B = FF₁₆ = 15Γ—16 + 15 = 255

Answer: rgb(30, 144, 255)

Example 3: Convert shorthand #F90 to RGB

Solution:

Expand shorthand: #F90 β†’ #FF9900

R = FF₁₆ = 255

G = 99₁₆ = 9Γ—16 + 9 = 153

B = 00₁₆ = 0

Answer: rgb(255, 153, 0) β€” a vibrant orange

Example 4: Convert #2C3E50 (Tailwind Dark Blue-Gray) to RGB

Solution:

Split into pairs: 2C, 3E, 50

R = 2C₁₆ = 2Γ—16 + 12 = 44

G = 3E₁₆ = 3Γ—16 + 14 = 62

B = 50₁₆ = 5Γ—16 + 0 = 80

Answer: rgb(44, 62, 80)

Practice Questions

Try converting these hex codes to RGB on your own:

  1. Convert #E74C3C to RGB. (Answer: rgb(231, 76, 60))
  2. Convert #3498DB to RGB. (Answer: rgb(52, 152, 219))
  3. Convert #2ECC71 to RGB. (Answer: rgb(46, 204, 113))
  4. Convert #9B59B6 to RGB. (Answer: rgb(155, 89, 182))
  5. Convert shorthand #ABC to full RGB. (Answer: #AABBCC β†’ rgb(170, 187, 204))
  6. What hex code gives rgb(0, 128, 128)? (Answer: #008080 β€” Teal)

Where Hex to RGB Conversion is Used

Web developers use hex colors in CSS stylesheets (#FF5733) but need RGB when working with JavaScript canvas APIs, CSS rgba() for transparency, or design tools like Figma that display RGB values. Game developers convert hex to RGB when loading color palettes from configuration files. Data visualization libraries often accept RGB tuples rather than hex strings. Image processing in Python (PIL/OpenCV) works exclusively with RGB arrays, so any hex color from a web design must be converted before use in code.

Common Mistakes in Hex to RGB Conversion

The most common mistake is treating hex digits as decimal. For example, reading "AF" as 1015 instead of correctly calculating 10Γ—16+15=175. Another frequent error is forgetting that shorthand codes (#F00) must be expanded by doubling each digit (#FF0000), not by adding zeros (#F00000 β€” this would be wrong). When copying hex codes from design tools, some include the # prefix and some do not β€” always strip it before parsing. Finally, watch the channel order: CSS uses #RRGGBB but some systems (like Android) use #AARRGGBB with an alpha channel prepended.

Key Takeaways

  • A hex color code is just three hexadecimal numbers (RR, GG, BB) packed into a 6-character string.
  • Each pair converts independently: hex pair β†’ decimal value (0-255) for that color channel.
  • Shorthand #RGB expands to #RRGGBB by doubling each digit (not padding with zeros).
  • Hex FF = decimal 255 (maximum), hex 00 = decimal 0 (minimum) for each channel.
  • The conversion is pure math: digit₁×16 + digitβ‚‚ = decimal value. No lookup tables needed.
  • CSS supports both formats interchangeably β€” #FF5733 and rgb(255, 87, 51) produce the identical color.

Related Converters: