RGB to Hex Color Converter
Written by Thierno Sadou Diallo, formula verified per our methodology • Last checked on 9/5/2026
A hexadecimal color code is obtained by converting each of the three red, green, and blue components (0 to 255) into a two-digit hexadecimal number, then joining them after a hash sign. The RGB color (255, 87, 51) thus gives the code #FF5733.
Explanation
Digital colors are generally expressed in two equivalent notations: RGB (red, green, blue), where each component is a decimal number from 0 to 255, and hexadecimal, where each component is converted to base 16 and shown as a compact code preceded by a hash sign (for example #FF5733). Hexadecimal notation is the most widely used in web development (CSS, HTML) and in most graphic design software, since it fits in a single short, easily copyable code, while RGB notation requires specifying three separate numbers. The conversion itself is a simple number-base change (see also our number base conversion calculator for the general principle): each component from 0 to 255 converts to a two-digit hexadecimal number, from 00 (no intensity) to FF (maximum intensity), with the letters A through F representing the values 10 through 15 in the hexadecimal system. This calculator only covers the RGB-to-hex direction, the most commonly sought one (starting from a visually chosen color to get its code to paste into code); many color pickers can perform the reverse conversion from an already-known hex code. Once you have the code, the aspect ratio calculator remains useful for laying out a visual using that color, such as a banner or an image with precise proportions.
Example: the RGB color (255, 87, 51)
Inputs
Red: 255. Green: 87. Blue: 51.
Calculation
255 in hexadecimal is FF, 87 is 57, and 51 is 33. Joining the three with a hash in front: #FF5733.
Result
The RGB color (255, 87, 51) corresponds to the hexadecimal code #FF5733.
Frequently asked questions
Why use two hexadecimal digits per component, not just one?
A single hexadecimal digit can only represent 16 values (0 to F), while each RGB component ranges from 0 to 255, or 256 possible values. Two hexadecimal digits let you encode exactly 256 values (16×16), which matches perfectly the 0-255 range used by each color component.
What do the letters A through F represent in a hexadecimal code?
The hexadecimal system uses 16 symbols to represent the digits 0 through 15: the usual digits 0 to 9 cover the first ten values, and the letters A through F (uppercase or lowercase, both are valid) cover the next six, from 10 (A) to 15 (F). That's why FF (15×16 + 15 = 255) represents the maximum value of a color component.
Can this calculator convert a hexadecimal code into RGB?
No, only in the RGB-to-hexadecimal direction. The reverse conversion would require entering a code as free text (for example "FF5733"), a field type this calculator doesn't currently offer; many online color pickers or those built into design software offer this reverse conversion.