HEX to RGB Color Converter
Enter the hex color code to convert to RGB or RGB to Hex.
#FF5733
Hex Color β RGB Breakdown
Red
255
Green
87
Blue
51
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
- Get the 2 left digits of the hex color code and convert to decimal β this is the Red value
- Get the 2 middle digits and convert to decimal β this is the Green value
- 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
| Color | Hex | R | G | B | Preview |
|---|---|---|---|---|---|
| Black | #000000 | 0 | 0 | 0 | |
| White | #FFFFFF | 255 | 255 | 255 | |
| Red | #FF0000 | 255 | 0 | 0 | |
| Lime | #00FF00 | 0 | 255 | 0 | |
| Blue | #0000FF | 0 | 0 | 255 | |
| Yellow | #FFFF00 | 255 | 255 | 0 | |
| Cyan | #00FFFF | 0 | 255 | 255 | |
| Magenta | #FF00FF | 255 | 0 | 255 | |
| Orange | #FFA500 | 255 | 165 | 0 | |
| Coral | #FF7F50 | 255 | 127 | 80 | |
| Tomato | #FF6347 | 255 | 99 | 71 | |
| Gold | #FFD700 | 255 | 215 | 0 | |
| Silver | #C0C0C0 | 192 | 192 | 192 | |
| Gray | #808080 | 128 | 128 | 128 | |
| Maroon | #800000 | 128 | 0 | 0 | |
| Navy | #000080 | 0 | 0 | 128 |
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:
- Convert #E74C3C to RGB. (Answer: rgb(231, 76, 60))
- Convert #3498DB to RGB. (Answer: rgb(52, 152, 219))
- Convert #2ECC71 to RGB. (Answer: rgb(46, 204, 113))
- Convert #9B59B6 to RGB. (Answer: rgb(155, 89, 182))
- Convert shorthand #ABC to full RGB. (Answer: #AABBCC β rgb(170, 187, 204))
- 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.