Skip to main content
Home/Tools/Developer/Hex to RGB Converter

Hex to RGB Converter

Convert a hexadecimal color code to its red, green and blue values for use in CSS rgb() and rgba().

100% Private - Runs Entirely in Your Browser
No data is sent to any server. All processing happens locally on your device.

Convert a hex color to RGB

A hex color code is a compact way to write a color as a six-digit hexadecimal string, like #3B82F6. RGB describes the same color as three decimal numbers — the amount of red, green, and blue light from 0 to 255. Converting from hex to RGB is useful whenever you need the rgb() or rgba() form in CSS, for example to add an alpha channel for transparency.

Enter or pick a color and the converter instantly shows its RGB values alongside HEX, HSL, and other formats, each ready to copy into your stylesheet.

How the hex-to-RGB math works

A hex color is just three pairs of hexadecimal digits, one pair per channel, in the order red, green, blue. Hexadecimal is base-16, so each pair represents a number from 00 to FF — that is 0 to 255 in decimal. To convert a pair, multiply the first digit by 16 and add the second:

  • #3B82F6 splits into 3B, 82, F6.
  • Red: 3B = (3 × 16) + 11 = 59.
  • Green: 82 = (8 × 16) + 2 = 130.
  • Blue: F6 = (15 × 16) + 6 = 246.

So #3B82F6 becomes rgb(59, 130, 246). The letters A–F stand for 10–15. Shorthand three-digit hex like #39F is expanded by doubling each digit (#3399FF) before converting.

When to use RGB instead of hex

Hex and RGB describe identical colors, so the choice is about convenience. RGB shines when you want an alpha channel: rgba(59, 130, 246, 0.5) gives a 50% transparent blue, something plain six-digit hex cannot express. RGB values are also easier to manipulate in JavaScript, since each channel is already a number you can add to or interpolate between — handy for animations, gradients, and generated themes.

Working with RGB in CSS

Drop the converted value straight into any color property: color: rgb(59, 130, 246); or background: rgba(59, 130, 246, 0.5);. Modern CSS also accepts a space-separated syntax, rgb(59 130 246 / 50%), which behaves the same way. Keep your most-used colors as CSS custom properties so you only convert each one once.

Hex and RGB are two views of one color

It helps to remember that converting between hex and RGB never changes the color itself — both notations point at the exact same red, green, and blue intensities, just written differently. That means you can move back and forth freely: author in whichever format is convenient, then convert to the other when a tool, teammate, or API expects it. Because the round trip is lossless, #3B82F6 and rgb(59, 130, 246) will always render as the identical shade of blue.

Loading interactive tool...

Convert a hex color to RGB

A hex color code is a compact way to write a color as a six-digit hexadecimal string, like #3B82F6. RGB describes the same color as three decimal numbers — the amount of red, green, and blue light from 0 to 255. Converting from hex to RGB is useful whenever you need the rgb() or rgba() form in CSS, for example to add an alpha channel for transparency.

Enter or pick a color and the converter instantly shows its RGB values alongside HEX, HSL, and other formats, each ready to copy into your stylesheet.

How the hex-to-RGB math works

A hex color is just three pairs of hexadecimal digits, one pair per channel, in the order red, green, blue. Hexadecimal is base-16, so each pair represents a number from 00 to FF — that is 0 to 255 in decimal. To convert a pair, multiply the first digit by 16 and add the second:

  • #3B82F6 splits into 3B, 82, F6.
  • Red: 3B = (3 × 16) + 11 = 59.
  • Green: 82 = (8 × 16) + 2 = 130.
  • Blue: F6 = (15 × 16) + 6 = 246.

So #3B82F6 becomes rgb(59, 130, 246). The letters A–F stand for 10–15. Shorthand three-digit hex like #39F is expanded by doubling each digit (#3399FF) before converting.

When to use RGB instead of hex

Hex and RGB describe identical colors, so the choice is about convenience. RGB shines when you want an alpha channel: rgba(59, 130, 246, 0.5) gives a 50% transparent blue, something plain six-digit hex cannot express. RGB values are also easier to manipulate in JavaScript, since each channel is already a number you can add to or interpolate between — handy for animations, gradients, and generated themes.

Working with RGB in CSS

Drop the converted value straight into any color property: color: rgb(59, 130, 246); or background: rgba(59, 130, 246, 0.5);. Modern CSS also accepts a space-separated syntax, rgb(59 130 246 / 50%), which behaves the same way. Keep your most-used colors as CSS custom properties so you only convert each one once.

Hex and RGB are two views of one color

It helps to remember that converting between hex and RGB never changes the color itself — both notations point at the exact same red, green, and blue intensities, just written differently. That means you can move back and forth freely: author in whichever format is convenient, then convert to the other when a tool, teammate, or API expects it. Because the round trip is lossless, #3B82F6 and rgb(59, 130, 246) will always render as the identical shade of blue.

You build the idea. I'll ship the product.

Productized MVP development for founders. 9 SaaS apps shipped — yours could be next, in 6 weeks. Secure by default.

Frequently Asked Questions

Common questions about the Hex to RGB Converter

Split the six-digit code into three pairs (red, green, blue). Convert each two-digit hexadecimal pair to decimal by multiplying the first digit by 16 and adding the second. For example, FF = (15 × 16) + 15 = 255.

It converts to rgb(59, 130, 246): 3B is 59, 82 is 130, and F6 is 246. The tool shows this conversion automatically along with other formats.

Expand the shorthand first by doubling each digit. For example #39F becomes #3399FF, which then converts to rgb(51, 153, 255).

RGB lets you add an alpha channel for transparency with rgba(), and the numeric channels are easier to manipulate in JavaScript for gradients, animations, and dynamically generated colors. Hex and RGB otherwise describe the exact same color.

ℹ️ Disclaimer

This tool is provided for informational and educational purposes only. All processing happens entirely in your browser - no data is sent to or stored on our servers. While we strive for accuracy, we make no warranties about the completeness or reliability of results. Use at your own discretion.