What RGB and HEX mean
RGB describes screen colors with three decimal channels: red, green and blue. Each channel ranges from 0 (none of that light) to 255 (full intensity). HEX represents the same channels with hexadecimal pairs from 00 to FF. A six-digit code follows #RRGGBB.
How to convert RGB to HEX
- Check that each RGB channel is a whole number from 0 to 255.
- Convert each decimal channel to base 16.
- Add a leading zero when a result has one digit.
- Join the red, green and blue pairs after
#.
Formula: # + hex(R) + hex(G) + hex(B). For rgb(255, 87, 51), 255 becomes FF, 87 becomes 57, and 51 becomes 33, giving #FF5733.
Using the result in CSS
HEX and RGB are interchangeable for solid sRGB colors. For example, color: #FF5733; and color: rgb(255, 87, 51); display the same color. HEX is compact for design tokens; RGB can be convenient when channel values are already available in code.
Common RGB to HEX colors
| Color | RGB | HEX |
|---|---|---|
| Black | rgb(0, 0, 0) | #000000 |
| White | rgb(255, 255, 255) | #FFFFFF |
| Red | rgb(255, 0, 0) | #FF0000 |
| Green | rgb(0, 128, 0) | #008000 |
| Blue | rgb(0, 0, 255) | #0000FF |
| Orange | rgb(255, 165, 0) | #FFA500 |
| Rebecca purple | rgb(102, 51, 153) | #663399 |
RGB to HEX questions
Are lowercase and uppercase HEX codes different?
No. #ff5733 and #FF5733 represent the same color; this tool uses uppercase for consistent output.
Can RGB channels contain decimals?
Standard 8-bit RGB channels are integers from 0 to 255. This converter asks you to correct decimals instead of silently rounding them.
What happens to invalid values?
Empty, negative, decimal, or above-255 channels show an error and do not replace the last valid result.