How RGB values become a HEX code
A screen color is made by mixing red, green and blue light. RGB writes each channel as a number from 0 (none) to 255 (full). A HEX code writes the same three channels as two-digit base-16 numbers placed one after the other, with a # in front.
To convert by hand, turn each channel into base 16. For rgb(91, 79, 240): 91 is 5B, 79 is 4F and 240 is F0, giving #5B4FF0. A channel below 16 needs a leading zero, so 5 becomes 05, not 5.
Both notations hold exactly the same information. HEX is simply shorter and is the form most often found in stylesheets, design hand-offs and brand guidelines.
When you need to go from RGB to HEX
A common case is that a design app, screenshot tool or color sampler reports a color as three separate numbers, while the place you are pasting it into wants a single code. CSS accepts both, but many theme settings, CMS color fields and email builders only take HEX.
It also helps when you are adjusting channels numerically. If you want a slightly stronger red, you can change one number and read off the new code instead of doing base-16 math.
If you are going the other way, the HEX to RGB converter splits a code back into its three numbers.
How to convert RGB to HEX with this tool
- Find the three boxes labeled R, G and B. They start at 91, 79 and 240.
- Type a number from 0 to 255 into each box.
- Look at the panel beneath the boxes. It shows the HEX code, such as #5B4FF0, in monospace type.
- Check the preview swatch on the right to confirm the color looks as expected, then select the code and copy it.
The code updates as you type and everything runs in your browser. There is no copy button, so you select the text yourself.
Common mistakes and limits
Channel values are not checked as strictly as you might expect. If you enter a number above 255 or below 0, the HEX output limits it to the valid range (so 300 behaves like 255 and -10 behaves like 0), and decimals are rounded to the nearest whole number. The result is a valid code, but it may not be the color you meant, so double-check typos such as 2400 for 240.
Clearing a box counts as 0. The tool outputs six-digit uppercase HEX only. It does not produce the three-digit shorthand and does not handle transparency, so rgba() values with an alpha channel cannot be converted here.
To see a color in more notations at once, use the color converter.