Hex to RGB Converter

Convert a hex color code numeric value to individual RGB components for web development.

Red (R)

59

Green (G)126
Blue (B)246

Hex to RGB Conversion

A hex color like #3B82F6 has a numeric value of 3,899,126.

Extracting Components

  • Red = floor(value / 65536)
  • Green = floor((value mod 65536) / 256)
  • Blue = value mod 256
  • Example: 3899126

  • R = floor(3899126 / 65536) = 59
  • G = floor((3899126 - 59*65536) / 256) = 130
  • B = 3899126 - floor(3899126/256)*256 = 246
  • Result: rgb(59, 130, 246)
  • Example Calculation

    Convert hex value 3899126 (#3B82F6) to RGB.

    1. 01R = floor(3899126 / 65536) = 59
    2. 02G = floor((3899126 mod 65536) / 256) = 130
    3. 03B = 3899126 mod 256 = 246
    4. 04Result: rgb(59, 130, 246)

    Frequently Asked Questions

    Learn More

    Metric vs Imperial: A Complete Guide to the Two Measurement Systems

    Understand the differences between the metric and imperial measurement systems. Learn their history, how they compare, and when to use each system for length, weight, volume, and temperature.

    Related Calculators