What is an RGB to Hex converter?
This tool turns an RGB color — three numbers between 0 and 255 representing the intensity of red, green and blue light — into a hexadecimal color code in the familiar #RRGGBB format used across web design, CSS, HTML, and graphic-design software. Both notations describe exactly the same color; hex is simply a more compact way to write the same three byte values.
How to use it
Enter a value from 0 to 255 for each of the Red, Green and Blue fields, then submit. The calculator returns the hex code, a live color swatch so you can see the result, and a breakdown showing each channel in both decimal and hexadecimal. Values outside 0-255 are automatically clamped, and decimals are rounded to the nearest whole number.
The formula explained
Each channel is converted to base 16. A byte from 0 to 255 always fits in exactly two hex digits (00 to FF). To convert a value v, take the high digit as floor(v / 16) and the low digit as v mod 16, mapping 10-15 to A-F. Single-digit results are zero-padded so every channel is two characters. The three two-digit pieces are then joined behind a #.
$$\text{Hex} = \text{\#} \; \overline{\text{Red}}_{16} \, \overline{\text{Green}}_{16} \, \overline{\text{Blue}}_{16}$$
Worked example
For RGB(255, 165, 0): Red 255 = FF, Green 165 = (\(165 \div 16 = 10\) remainder 5) → A5, Blue 0 = 00. Concatenated this gives #FFA500, the classic web color "orange".
FAQ
Why are some hex codes only 3 digits? Shorthand like #FFF expands #RRGGBB where each pair repeats (so #FFF = #FFFFFF). This tool always outputs the full 6-digit form.
What does FF mean? FF is hexadecimal for 255, the maximum intensity of a channel.
Can I enter values above 255? Channels only range 0-255, so larger inputs are clamped to 255 (and negatives to 0).