CalcuClubCalcuClub Logo

RGB to Hexadecimal Converter

Enter the RGB color value

Red:
Green:
Blue:
Result:
Hexadecimal Value:
CSS Color:
Preview:
Red:
00
Green:
00
Blue:
00

Table of Contents

How does the RGB to Hexadecimal Conversion Work?

The RGB to hexadecimal conversion is based on transforming the three main color components —Red, Green, and Blue— into their equivalent hexadecimal values. While RGB uses decimal values ranging from 0 to 255, the hexadecimal format uses values from 00 to FF. The hexadecimal system has a base of 16, meaning its digits are represented by the numbers 0 to 9 and the letters A to F.

👉 Learn more about the RGB format

Conversion Process

The process of converting RGB to hexadecimal involves converting each decimal RGB value to its hexadecimal equivalent. The process is simple:

  1. Take the RGB values.
    For example: RGB(34, 139, 34).
  2. Convert each decimal value to hexadecimal.
    For red (34): The hexadecimal equivalent is 22.
    For green (139): The hexadecimal equivalent is 8B.
    For blue (34): The hexadecimal equivalent is 22.
  3. Combine the hexadecimal values.
    Combine the three hexadecimal values to get the final code: #228B22.

Complete Example of RGB to Hexadecimal Conversion

Suppose you want to convert the color represented by RGB(255, 165, 0) to hexadecimal.

  1. Red value (255):
    The hexadecimal equivalent is FF.
  2. Green value (165):
    The hexadecimal equivalent is A5.
  3. Blue value (0): The hexadecimal equivalent is 00.

The final hexadecimal code is #FFA500, which represents the color orange.

RGB to Hexadecimal Conversion Formula

The formula for converting an RGB value to its hexadecimal equivalent is fairly straightforward. For each color component:

  1. Take the RGB value (a number between 0 and 255).
  2. Divide this value by 16 to get the quotient and the remainder.
  3. The quotient represents the first hexadecimal digit, and the remainder represents the second.

Example

  • If the RGB value is 198:
    • Divide 198 by 16, which gives 12 with a remainder of 6.
    • The 12 is represented in hexadecimal as C, and the 6 as 6.
    • The hexadecimal value of 198 is therefore C6.

Applying this method to the three components (Red, Green, and Blue) will give you the complete hexadecimal code.

How was this page? Share feedback.