CalcuClubCalcuClub Logo

Hex to RGB Converter

Enter the hexadecimal value of the color

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

Table of Contents

How does the hexadecimal to RGB conversion work?

In computing, especially in web design, colors are commonly represented in two formats: hexadecimal (base 16) and RGB (red, green, blue, base 10). Both formats describe the intensity of the three primary colors (red, green, and blue) that, combined in various proportions, create any visible color on a screen.

Hexadecimal Format

A color in hexadecimal format consists of a six-character value, which can include digits from 0 to 9 and letters from A to F. Each pair of characters corresponds to one of the primary colors (red, green, or blue). The hexadecimal value is structured as follows: #RRGGBB

  • RR: Corresponds to the intensity of red.
  • GG: Corresponds to the intensity of green.
  • BB: Corresponds to the intensity of blue.

RGB Format

The RGB format describes the same color using three decimal values (base 10), where each value represents the intensity of one of the primary colors. Each value can range from 0 to 255: RGB(R, G, B)

  • R: Intensity of red (from 0 to 255).
  • G: Intensity of green (from 0 to 255).
  • B: Intensity of blue (from 0 to 255).

Conversion Process

To convert a color from hexadecimal to RGB, follow these steps:

  1. Separate the hexadecimal components: Take the six-character hexadecimal value (for example, #1A2B3C) and split it into three parts:
    • RR = 1A (for red)
    • GG = 2B (for green)
    • BB = 3C (for blue)
  2. Convert each hexadecimal pair to decimal:
    • The hexadecimal value is converted to decimal using the conversion formula from base 16 to base 10.
    • For red (RR = 1A):
      • 1A in hexadecimal is equivalent to 26 in decimal.
    • For green (GG = 2B):
      • 2B in hexadecimal is equivalent to 43 in decimal.
    • For blue (BB = 3C):
      • 3C in hexadecimal is equivalent to 60 in decimal.
  3. Final result in RGB format:
    • The hexadecimal color #1A2B3C is converted to RGB as: RGB(26, 43, 60)

Full Example:

  • Hexadecimal color: #FF5733
    • Red (RR): FF in hexadecimal is 255 in decimal.
    • Green (GG): 57 in hexadecimal is 87 in decimal.
    • Blue (BB): 33 in hexadecimal is 51 in decimal.
  • Result in RGB format: RGB(255, 87, 51)

Conversion Formula

To convert each hexadecimal component (RR, GG, BB) to decimal, we use the following formula:

Decimal value = (Left digit × 16) + (Right digit × 1)

For example, for 1A (red):

  • 1 (left digit) = 1 in decimal.
  • A (right digit) = 10 in decimal (in hexadecimal).

Applying the formula:

(1 × 16) + (10 × 1) = 16 + 10 = 26

How was this page? Share feedback.