Converter

Hex to RGB Converter | Hexadecimal to RGB Color Code Calculator

Free Hex to RGB converter with instant calculations. Convert hexadecimal color codes to RGB values with formulas, color preview, and detailed conversion guide for web designers.
Hex to RGB Conversion

Hex to RGB Converter

Welcome to the comprehensive Hex to RGB color code converter designed to help web designers, developers, and digital artists convert hexadecimal color codes to RGB decimal values with instant calculations, visual previews, and detailed mathematical formulas.

Interactive Hex to RGB Converter

Enter with or without # symbol (e.g., #FF0000 or FF0000)

#FF0000
RGB(255, 0, 0)

Conversion Results

RED

255

GREEN

0

BLUE

0

CSS Output:

color: rgb(255, 0, 0);
background: #FF0000;
background-color: rgb(255, 0, 0);

Understanding Hexadecimal Color Codes

What is a Hex Color Code?

Hexadecimal (hex) color codes are a compact way to represent RGB colors using base-16 notation. A hex color code consists of a hash symbol (#) followed by six hexadecimal digits, where each pair of digits represents the intensity of red, green, and blue respectively. Hex codes are the most common format for specifying colors in web development because they're concise, easy to copy, and universally supported in HTML and CSS.

Hex Code Structure

  • Format: #RRGGBB where each pair is a hexadecimal number (00-FF)
  • RR: Red channel intensity from 00 (0) to FF (255)
  • GG: Green channel intensity from 00 (0) to FF (255)
  • BB: Blue channel intensity from 00 (0) to FF (255)
  • Short Form: #RGB expands to #RRGGBB (e.g., #F00 = #FF0000)
  • Case Insensitive: #FF0000 and #ff0000 are equivalent

Hex to RGB Conversion Formulas

Hexadecimal Number System

\[ \text{Hex Digits:} \quad 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F \] \[ \text{Where:} \quad A=10, B=11, C=12, D=13, E=14, F=15 \]

Conversion Formula for Each RGB Channel

\[ \text{RGB Value} = (d_1 \times 16) + d_0 \]

Where \(d_1\) = first hex digit, \(d_0\) = second hex digit

\[ R = (R_1 \times 16) + R_0 \] \[ G = (G_1 \times 16) + G_0 \] \[ B = (B_1 \times 16) + B_0 \]

Alternative: Base-16 to Base-10 Conversion

\[ \text{Decimal} = d_1 \times 16^1 + d_0 \times 16^0 \]

Each hex pair is converted from base-16 to base-10 (decimal)

Hexadecimal to Decimal Reference

HexDecimalHexDecimalHexDecimal
0005585AA170
111766102BB187
223477119CC204
335188136DD221
446899153EE238
FF255801284064

Common Hex to RGB Conversions

Color NameHex CodeRGBShort Hex
White#FFFFFFRGB(255, 255, 255)#FFF
Black#000000RGB(0, 0, 0)#000
Red#FF0000RGB(255, 0, 0)#F00
Green#00FF00RGB(0, 255, 0)#0F0
Blue#0000FFRGB(0, 0, 255)#00F
Yellow#FFFF00RGB(255, 255, 0)#FF0
Cyan#00FFFFRGB(0, 255, 255)#0FF
Magenta#FF00FFRGB(255, 0, 255)#F0F
Gray#808080RGB(128, 128, 128)-

Step-by-Step Conversion Examples

Example 1: Convert #3A7F2C to RGB

Step 1: Separate into pairs

Red: 3A | Green: 7F | Blue: 2C

Step 2: Convert each pair

Red (3A): First digit = 3, Second digit = A (10)

R = (3 × 16) + 10 = 48 + 10 = 58

Green (7F): First digit = 7, Second digit = F (15)

G = (7 × 16) + 15 = 112 + 15 = 127

Blue (2C): First digit = 2, Second digit = C (12)

B = (2 × 16) + 12 = 32 + 12 = 44

Result: RGB(58, 127, 44)

Color Preview: #3A7F2C

Example 2: Convert #C8B = #CC88BB to RGB

Step 1: Expand short form

#C8B expands to #CC88BB (each digit doubled)

Step 2: Convert pairs

Red (CC): (12 × 16) + 12 = 192 + 12 = 204

Green (88): (8 × 16) + 8 = 128 + 8 = 136

Blue (BB): (11 × 16) + 11 = 176 + 11 = 187

Result: RGB(204, 136, 187)

Color Preview: #CC88BB

Short Hex Notation

Three-Digit Hex Codes

When each RGB channel pair has identical digits, you can use three-digit hex notation. The browser automatically expands each digit by duplicating it. This shorthand is more concise and easier to type for certain colors.

Expansion Rules

  • #RGB → #RRGGBB: Each digit is duplicated
  • #F00 → #FF0000: Pure red
  • #0F0 → #00FF00: Pure green
  • #00F → #0000FF: Pure blue
  • #FFF → #FFFFFF: White
  • #000 → #000000: Black

Practical Applications

Web Development

Hex codes are the standard for CSS color specification. Web designers frequently receive design files with hex codes from tools like Figma, Adobe XD, or Photoshop and need to convert them to RGB for CSS rgba() functions (which include transparency), canvas operations, or JavaScript color manipulation. Understanding the conversion helps debug color issues and manually adjust color values.

Color Manipulation

Converting hex to RGB is the first step in programmatic color manipulation. RGB values are easier to work with mathematically for tasks like lightening/darkening colors, calculating color averages, or implementing custom color mixing algorithms. JavaScript, Python, and other programming languages typically work with RGB values internally, requiring hex-to-RGB conversion for user-provided color codes.

Accessibility and Contrast

WCAG (Web Content Accessibility Guidelines) contrast calculations require RGB values to determine if text and background color combinations meet accessibility standards. Converting hex codes to RGB enables programmatic contrast checking, ensuring your website meets accessibility requirements for visually impaired users.

Common Questions

How do I convert hex to RGB manually?

Break the hex code into three pairs (RR, GG, BB). For each pair, multiply the first digit by 16 and add the second digit. Remember that hex digits A-F represent decimal 10-15. For example, #A5 = (10 × 16) + 5 = 165. This process converts from base-16 (hexadecimal) to base-10 (decimal) number system.

What does each hex digit represent?

Hexadecimal uses 16 digits: 0-9 represent their decimal values, while A=10, B=11, C=12, D=13, E=14, and F=15. Each position in a hex number represents a power of 16, so in a two-digit hex number like A5, the first digit (A) is worth A×16 and the second digit (5) is worth 5×1. This base-16 system allows two digits to represent values from 0 to 255 (16²-1).

Why use hex instead of RGB in CSS?

Hex codes are more compact (#FF0000 vs rgb(255, 0, 0)), don't require commas or spaces (reducing syntax errors), and have been the web standard since early HTML. However, RGB format is useful when you need transparency (rgba) or when programmatically generating colors. Modern CSS supports both, so choose based on your specific needs—hex for simplicity, RGB for transparency or manipulation.

Can I use three-digit hex codes everywhere?

Three-digit hex codes (#RGB) work in all modern browsers and expand to six digits (#RRGGBB). However, they only work when each channel pair has identical digits. #F00 works (expands to #FF0000), but you cannot use three digits to represent #FF5500—you must use the full six-digit form. Use three-digit codes for convenience with simple colors, six-digit codes for precise color control.

How do I convert hex to RGB with alpha channel?

First convert hex to RGB using the standard method. For transparency, either use eight-digit hex codes (#RRGGBBAA supported in modern CSS) or convert to rgba() format. The alpha channel (0-1 in rgba, or 00-FF in eight-digit hex) represents opacity: 0/00 = fully transparent, 1/FF = fully opaque. For example, #FF000080 or rgba(255, 0, 0, 0.5) both represent 50% transparent red.

Why Choose RevisionTown Resources?

RevisionTown is committed to providing accurate, user-friendly calculators and educational resources across diverse topics. While we specialize in mathematics education for curricula like IB, AP, GCSE, and IGCSE, we also create practical tools for technical applications like this Hex to RGB converter.

Our converter combines mathematical precision with instant visual feedback and detailed explanations to help web designers, developers, and students understand hexadecimal color codes and convert them accurately to RGB format.

About the Author

Adam

Co-Founder at RevisionTown

Math Expert specializing in various curricula including IB, AP, GCSE, IGCSE, and more

Connect on LinkedIn

info@revisiontown.com

Adam brings extensive experience in mathematics education and creating practical educational tools. As co-founder of RevisionTown, he combines analytical precision with user-focused design to develop calculators and resources that serve students, professionals, and individuals across various domains. His commitment to accuracy and clarity extends to all RevisionTown projects, ensuring users receive reliable, easy-to-understand information for their needs.

Note: This Hex to RGB converter uses standard base-16 to base-10 conversion formulas. Hex codes can be entered with or without the # symbol, and are case-insensitive. Three-digit hex codes (#RGB) are automatically expanded to six digits (#RRGGBB). All conversions follow W3C web standards and are compatible with HTML, CSS, and modern browsers. For hex codes with alpha transparency, use eight-digit format (#RRGGBBAA) or convert to rgba() format. Always test colors across different browsers and devices to ensure consistent appearance.

Shares: