RGB to HEX converter
Similar colors
Convert RGB to HEX online
Type or paste an RGB color, such as 255, 182, 193 or rgb(255 182 193), and the HEX code appears next to it. You can also pick the color by eye.
RGB to HEX formula
- Take the red value and divide it by 16. The whole-number result is the first character and the remainder is the second.
- Write 10 to 15 as A to F.
- Do the same with green and blue, and put # in front of the six characters.
- Example: 255 is 15 and 15, or FF. 182 is 11 and 6, or B6. 193 is 12 and 1, or C1. So RGB 255, 182, 193 is #FFB6C1.
const rgbToHex = (r, g, b) =>
'#' + [r, g, b].map(n => n.toString(16).padStart(2, '0')).join('');
rgbToHex(255, 182, 193); // '#ffb6c1'RGB to HEX table of common colors
| Color | RGB | HEX |
|---|---|---|
| Black | 0, 0, 0 | #000000 |
| White | 255, 255, 255 | #FFFFFF |
| Gray | 128, 128, 128 | #808080 |
| Red | 255, 0, 0 | #FF0000 |
| Maroon | 128, 0, 0 | #800000 |
| Orange | 255, 165, 0 | #FFA500 |
| Gold | 255, 215, 0 | #FFD700 |
| Yellow | 255, 255, 0 | #FFFF00 |
| Green | 0, 128, 0 | #008000 |
| Teal | 0, 128, 128 | #008080 |
| Cyan | 0, 255, 255 | #00FFFF |
| Blue | 0, 0, 255 | #0000FF |
| Navy Blue | 0, 0, 128 | #000080 |
| Purple | 128, 0, 128 | #800080 |
| Magenta | 255, 0, 255 | #FF00FF |
| Pink | 255, 192, 203 | #FFC0CB |
Frequently asked questions
What is the highest RGB value?
255. Each of the three channels goes from 0 to 255, which is 256 values and fits exactly into two HEX characters.
Why does my HEX code start with a zero?
A value under 16 needs a leading zero: 5 becomes 05. Without it, the code would have only five characters and would not work.
Can I convert RGBA to HEX?
Yes, with eight characters. The last two are the opacity times 255: 50% is 128, which is 80 in HEX, so rgba(255, 0, 0, 0.5) is #FF000080. Enter the three color numbers here and add the last two characters yourself.