NumForge LogoNumForge
Explore
Coding & Computer Number ToolsFree Interactive Tool

Hex to RGB Converter

Convert 6-digit and 3-digit hex color strings into decimal RGB channels (0-255) with live color preview. Designed for software developers, electrical engineers, students, and computer architecture researchers requiring deterministic client-side accuracy.

Engine: Client-Side Verified (0ms Latency)

Enter 3 or 6 character hex color code.

Calculated Output

Primary Representation
Calculating...

Step-by-Step Mathematical Proof

Active Derivation
Ready. Enter input above to generate derivation.
Concept

What Is Hex to RGB Converter?

Hex to RGB conversion parses a 6-digit or shorthand 3-digit hexadecimal color code into its three constituent decimal color channels: Red, Green, and Blue (each ranging from 0 to 255).

Methodology

How Does It Work?

Strips the leading # symbol. Extracts the first pair of hex digits for Red, second pair for Green, and third pair for Blue. Converts each pair from base 16 to base 10.

Formula & Rules

Mathematical Algorithm

R = \text{dec}(h_1 h_2), \quad G = \text{dec}(h_3 h_4), \quad B = \text{dec}(h_5 h_6)
Worked Problem

Step-by-Step Example

Convert #0066CC: Red: 00_{16} = 0 Green: 66_{16} = (6×16) + 6 = 102 Blue: CC_{16} = (12×16) + 12 = 204 Result: RGB(0, 102, 204).

Important Rules & Edge Cases

  • 3-digit shorthand (#RGB) expands by doubling each digit (#RRGGBB).
  • Allowed characters are 0-9 and A-F.

Practical Applications in Engineering

  • Web styling and converting CSS hex colors to rgba() for opacity manipulation.
  • Canvas 2D and WebGL shader color uniform configuration.
  • Mobile application development (SwiftUI, Jetpack Compose).

Common Mistakes to Avoid

  • Caution: Treating 3-digit hex #123 as #010203 instead of #112233.
  • Caution: Entering invalid characters like #ZZ0000.
FAQ

Frequently Asked Questions

How does shorthand 3-digit hex work?

Each digit is repeated twice: #06C becomes #0066CC.