How to Convert HEX to RGB Color Codes
HEX and RGB are two ways of writing the exact same colors. Designers and developers switch between them constantly — HEX in CSS stylesheets, RGB in JavaScript animations, HSL in design tools. Understanding how they relate makes color work much easier.
How HEX colors work
A HEX color code like #FF5733 is a 6-digit hexadecimal number that represents red, green, and blue channels:
| Part | Hex | Decimal | Channel |
|---|---|---|---|
| FF | FF | 255 | Red |
| 57 | 57 | 87 | Green |
| 33 | 33 | 51 | Blue |
Each channel ranges from 00 (0, no color) to FF (255, full intensity). So #FF5733 means full red, some green, a little blue — which gives you a warm orange-red.
How to convert HEX to RGB
- Enter your HEX code — type or paste a color code like #FF5733 or use the color picker.
- View the RGB values — see the equivalent red, green, and blue values (0-255 each).
- Copy in any format — grab the values as
rgb(255, 87, 51), individual channels, or other formats like HSL.
Common color codes
| Color | HEX | RGB |
|---|---|---|
| White | #FFFFFF | rgb(255, 255, 255) |
| Black | #000000 | rgb(0, 0, 0) |
| Red | #FF0000 | rgb(255, 0, 0) |
| Green | #00FF00 | rgb(0, 255, 0) |
| Blue | #0000FF | rgb(0, 0, 255) |
| Yellow | #FFFF00 | rgb(255, 255, 0) |
Tips
- Use HEX in CSS —
color: #FF5733is cleaner and more common thancolor: rgb(255, 87, 51)in stylesheets. - Use RGB for transparency — when you need semi-transparent colors, use
rgba(255, 87, 51, 0.5). There is no way to add alpha in standard HEX (though 8-digit HEX exists, browser support varies). - 3-digit shorthand —
#F00is the same as#FF0000. Use it when each pair has identical digits to save space. - Color picker is faster — if you are trying to find the right color, use the visual color picker instead of guessing HEX values. Copy the code once you are happy with the result.
Frequently Asked Questions
How do I convert HEX to RGB manually?
Split the 6-digit hex code into three pairs (e.g.,
What about 3-digit HEX codes?
Three-digit hex is shorthand where each digit is doubled.
When should I use HEX vs RGB?
HEX is more compact and widely used in CSS. RGB is better when you need to manipulate individual color channels programmatically or use rgba() for transparency. Both represent the same colors.
What is the
The hash (#) is a prefix that identifies the value as a hexadecimal color code. It is not part of the color value itself. Some tools accept HEX codes with or without the hash.