Type red, green and blue values to get the hex code, with every step of the conversion shown.
Red, green and blue, 0 to 255
How this code is worked out
Going the other way? Use hex to RGB. For HSL, CMYK and the other codes of a color, type it into the color picker.
Hexadecimal counts in sixteens, so it has sixteen digits. After 9 come the letters A to F. Two hex digits cover every value from 0 to 255: 00 is 0 and FF is 15 × 16 + 15 = 255.
| Hex digit | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Value | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| Color | RGB | Hex |
|---|---|---|
| Black | 0, 0, 0 | #000000 |
| Gray | 128, 128, 128 | #808080 |
| Silver | 192, 192, 192 | #C0C0C0 |
| White | 255, 255, 255 | #FFFFFF |
| Maroon | 128, 0, 0 | #800000 |
| Red | 255, 0, 0 | #FF0000 |
| Olive | 128, 128, 0 | #808000 |
| Yellow | 255, 255, 0 | #FFFF00 |
| Green | 0, 128, 0 | #008000 |
| Lime | 0, 255, 0 | #00FF00 |
| Teal | 0, 128, 128 | #008080 |
| Aqua (cyan) | 0, 255, 255 | #00FFFF |
| Navy (navy blue) | 0, 0, 128 | #000080 |
| Blue | 0, 0, 255 | #0000FF |
| Purple | 128, 0, 128 | #800080 |
| Fuchsia | 255, 0, 255 | #FF00FF |
Divide each of the three values by 16. Write the whole number and the remainder as hex digits, where 10 to 15 become A to F. Join the three pairs and put a # in front. For 255, 165, 0 the pairs are FF, A5 and 00, so the code is #FFA500.
#FFFFFF, which is white. Each 255 becomes FF, the largest two-digit hex number. Black, rgb(0, 0, 0), is #000000.
Yes. Both give the same three amounts of red, green and blue, one counted in sixteens and one in tens. Nothing is rounded, so no color is lost in either direction.
Hexadecimal counts in sixteens, so it needs sixteen digits. After 0 to 9 come A, B, C, D, E and F, which stand for 10 to 15. Two hex digits cover 0 to 255, exactly the range of one color value.
No. #ffa500 and #FFA500 are the same color in CSS, HTML and design tools.
A short form for codes whose pairs are doubled digits. #FA0 means #FFAA00: each digit is written twice. Only codes like that can be shortened.
Add a fourth pair for the opacity. Multiply the opacity by 255 and convert the result like a color value: 50% gives 128, which is 80 in hex, so rgb(255 165 0 / 50%) is #FFA50080.
Multiply each percentage by 2.55 and round to a whole number first. 100% is 255 and 50% is 128. You can also paste a value with percentages into the field here.