HEX to RGB
Type or paste a HEX color code and get its red, green, and blue values right away. The # is optional and upper or lower case both work.
#FF5733Resultrgb(255, 87, 51)Convert a HEX color code to RGB, or RGB values back to HEX. You also get RGBA and HSL, a live preview, and a text contrast check. Everything runs in your browser, so your data stays on your device.
Like #FF5733, #F53, or #FF573380
Like 255, 87, 51 or rgba(255, 87, 51, 0.5)
A HEX color code is a # followed by six characters, like #FF5733. The first two characters set how much red is in the color, the next two set green, and the last two set blue. Each pair is a number from 00 to FF in base 16, which is the same as 0 to 255 in the RGB system. HEX codes are short and easy to copy, so they are the most common way to write colors in CSS and design apps. This tool turns a HEX code into its RGB numbers and back again.
Type or paste a HEX color code and get its red, green, and blue values right away. The # is optional and upper or lower case both work.
#FF5733Resultrgb(255, 87, 51)Enter three RGB values from 0 to 255 and get the matching HEX code. You can paste plain numbers or a full CSS value like rgb(255, 87, 51).
rgb(255, 87, 51)Result#FF5733Reads 3-digit shorthand codes and 8-digit codes with an alpha (transparency) value. The alpha is turned into an RGBA value between 0 and 1.
#F538Resultrgba(255, 85, 51, 0.53)Also shows the color as HSL and as RGB values from 0 to 1, which some apps and game engines use instead of 0 to 255.
#FF5733Resulthsl(11, 100%, 60%)Split the HEX code into three pairs of characters. Each pair is a base 16 number, where the letters A to F stand for 10 to 15. Multiply the first character by 16 and add the second one. Here is #FF5733 worked out:
| Channel | HEX pair | Math | RGB value |
|---|---|---|---|
| Red | FF | 15 × 16 + 15 | 255 |
| Green | 57 | 5 × 16 + 7 | 87 |
| Blue | 33 | 3 × 16 + 3 | 51 |
So #FF5733 is rgb(255, 87, 51). To go from RGB to HEX, do the reverse. Divide each number by 16. The whole part is the first character and the remainder is the second. For example, 87 ÷ 16 is 5 with 7 left over, which gives 57.
These are the basic web colors with their HEX codes and RGB values.
| Color | HEX | RGB |
|---|---|---|
| Black | #000000 | rgb(0, 0, 0) |
| White | #FFFFFF | rgb(255, 255, 255) |
| Red | #FF0000 | rgb(255, 0, 0) |
| Green (lime) | #00FF00 | rgb(0, 255, 0) |
| Blue | #0000FF | rgb(0, 0, 255) |
| Yellow | #FFFF00 | rgb(255, 255, 0) |
| Cyan | #00FFFF | rgb(0, 255, 255) |
| Magenta | #FF00FF | rgb(255, 0, 255) |
| Orange | #FFA500 | rgb(255, 165, 0) |
| Purple | #800080 | rgb(128, 0, 128) |
| Gray | #808080 | rgb(128, 128, 128) |
| Navy | #000080 | rgb(0, 0, 128) |
Designers and developers switch between color formats all the time. Here are the most common reasons:
Working with colors and styles? These tools run the same way, right in your browser: