What is an RGB to Hex Converter?
This tool turns an RGB color — three channels (Red, Green, Blue) each ranging from 0 to 255 — into a hexadecimal color code in the form #RRGGBB. Hex codes are the standard way to specify colors in HTML, CSS, SVG and most design software, so converting from RGB is a daily task for web developers and designers.
How to Use It
Enter your Red, Green and Blue values, each between 0 and 255, then read off the resulting hex code and preview swatch. Values outside the range are automatically clamped to 0-255.
The Formula Explained
Each channel value (0-255) is written as a two-digit base-16 number. The first digit is the value divided by 16 (the high nibble) and the second is the remainder when divided by 16 (the low nibble), using digits 0-9 and A-F. The three two-digit results are joined after a leading #:
$$\text{Hex} = \text{\#} \, \overline{\text{Red}}_{16} \, \overline{\text{Green}}_{16} \, \overline{\text{Blue}}_{16}$$
Worked Example
Take "tomato": \(R=255\), \(G=99\), \(B=71\). For R: \(255 \div 16 = 15 \to F\), remainder \(15 \to F\), so "FF". For G: \(99 \div 16 = 6 \to 6\), remainder \(3 \to 3\), so "63". For B: \(71 \div 16 = 4 \to 4\), remainder \(7 \to 7\), so "47". Concatenated: #FF6347.
FAQ
Why is the hex code 6 digits? Two hex digits represent each of the three channels (\(2 \times 3 = 6\)), covering all 16,777,216 possible colors.
Can I use uppercase or lowercase? Both are valid in CSS. This tool outputs uppercase letters (A-F); #ff6347 and #FF6347 are identical.
What about transparency? Standard hex codes have no alpha channel. An 8-digit #RRGGBBAA form adds opacity, but this converter produces the common 6-digit code.