RGB to HEX converter
Type an rgb() color to get its hex code, or edit the hex field to go the other way. The color picker and HSL value update as you type.
#1E90FF = rgb(30, 144, 255) = hsl(210, 100%, 56%)
How to convert RGB to HEX
An RGB color has three channels, red, green and blue, each from 0 to 255. A hex color code writes each channel as a two-digit hexadecimal number, so the format is #RRGGBB. To convert by hand:
- Take one channel, for example red = 255.
- Divide by 16: the whole number is the first digit, the remainder the second. 255 ÷ 16 = 15 remainder 15.
- Write 10 to 15 as A to F: 15 and 15 become FF.
- Repeat for green and blue and join them: rgb(255, 99, 71) becomes #FF6347.
Going the other way? Use the HEX to RGB converter.
RGB to HEX color chart
| Color | RGB | HEX |
|---|---|---|
| Black | rgb(0, 0, 0) | #000000 |
| White | rgb(255, 255, 255) | #FFFFFF |
| Red | rgb(255, 0, 0) | #FF0000 |
| Lime | rgb(0, 255, 0) | #00FF00 |
| Blue | rgb(0, 0, 255) | #0000FF |
| Orange | rgb(255, 165, 0) | #FFA500 |
| Gold | rgb(255, 215, 0) | #FFD700 |
| Tomato | rgb(255, 99, 71) | #FF6347 |
| Teal | rgb(0, 128, 128) | #008080 |
| Slate gray | rgb(112, 128, 144) | #708090 |
| Indigo | rgb(75, 0, 130) | #4B0082 |
| Hot pink | rgb(255, 105, 180) | #FF69B4 |
Decimal to hex for one channel
Common channel values and their two-digit hex codes:
| Decimal | Hex |
|---|---|
| 0 | 00 |
| 17 | 11 |
| 34 | 22 |
| 51 | 33 |
| 68 | 44 |
| 85 | 55 |
| 102 | 66 |
| 119 | 77 |
| 128 | 80 |
| 136 | 88 |
| 153 | 99 |
| 170 | AA |
| 187 | BB |
| 204 | CC |
| 221 | DD |
| 238 | EE |
| 255 | FF |
RGBA to HEX
CSS also accepts 8-digit hex codes, where the last two digits are the alpha (opacity). Multiply the alpha by 255 and convert it like any other channel: 1 = FF, 0.75 ≈ BF, 0.5 ≈ 80, 0.25 ≈ 40 and 0 = 00. So rgba(30, 144, 255, 0.5) is #1E90FF80.
Check these values on any live website
Traceo is a free Chrome extension that shows the real CSS on any page: hover an element to read its colors in HEX and RGB, font sizes in px and rem, spacing, and contrast, then record and share UI bugs with console and network logs.
FAQ
How do you convert RGB to HEX?
Convert each of the red, green and blue values (0 to 255) to a two-digit hexadecimal number, then join them after a # sign. For rgb(255, 99, 71): 255 = FF, 99 = 63, 71 = 47, so the hex code is #FF6347.
How do you convert a single number from decimal to hex?
Divide the number by 16. The whole part is the first hex digit and the remainder is the second, where 10 to 15 are written A to F. For 99: 99 ÷ 16 = 6 remainder 3, so 99 is 63 in hex.
How do I convert RGBA to HEX?
Convert red, green and blue as usual, then convert the alpha to a two-digit hex value by multiplying it by 255 and rounding. rgba(255, 99, 71, 0.5) becomes #FF634780, because 0.5 × 255 ≈ 128 = 80 in hex.
Is RGB or HEX better for CSS?
They describe the same colors, so use whichever is easier to read. Hex is shorter and easy to copy from design tools; rgb() is clearer when you need to adjust a channel or add transparency with rgb(255 99 71 / 50%).
Why does my HEX code have letters?
Hexadecimal counts from 0 to 15 in a single digit, using A to F for 10 to 15. Two hex digits cover 0 to 255, which is exactly the range of one RGB channel.
How do I get the RGB or HEX value of a color on a website?
With the Traceo Chrome extension, hover any element to see the colors the page renders in both HEX and RGB, or list the full color palette of the page.