HEX to RGB Converter

Convert hexadecimal web color codes to RGB system values instantly.

#

Invalid HEX format.

#3B82F6

Enter a valid transparent HEX code to see its RGB equivalent.

How to Use

1

Enter the hex color code

Type a 3 or 6-character hex code with or without the # prefix (e.g. #FF5733 or FF5733).

2

View RGB channel values

See the Red, Green, and Blue values (0–255) instantly extracted from the hex code.

3

Copy in your preferred format

Copy individual channel numbers or the full rgb()/rgba() CSS function string.

4

Apply in CSS or code

Use the RGB values in stylesheets, canvas APIs, image editors, or any RGB-based color input.

Understanding HEX & RGB

HEX and RGB are the two standard ways web browsers render colors. Sometimes developers need to translate one to the other to apply CSS opacity filters or blend modes. This tool completely eliminates the manual math required to do so.

Real-World Examples & Use Cases

CSS rgba() Transparency Effects

The CSS rgba() function requires individual RGB channel numbers to add opacity — you cannot add transparency directly to a hex code. A designer who has a brand color #3B82F6 needs to create a semi-transparent overlay for modal backgrounds. Converting to rgb(59, 130, 246) and then using rgba(59, 130, 246, 0.5) produces a 50% transparent version. Hover states, glassmorphism effects, and color-blend overlays all require RGB values rather than hex notation.

JavaScript Canvas and WebGL Color Values

The HTML5 Canvas API and WebGL use RGB or normalized float values (0.0–1.0) rather than hex strings for direct color assignment. Drawing primitives with fillStyle, strokeStyle, or passing colors to WebGL shader uniforms requires converting hex codes from design tools into numeric RGB values. Dividing each channel by 255 produces the 0.0–1.0 float range needed by WebGL: rgb(255, 87, 51) becomes vec3(1.0, 0.341, 0.2) in GLSL shader code.

Bridging Design Tools and Development

Design tools like Figma, Sketch, and Adobe XD display colors as hex codes in their color panels. When developers implement these designs in CSS, React Native, or native mobile code, some contexts require RGB values. React Native's StyleSheet expects colors as hex strings for most uses but platform-specific APIs sometimes require RGB components. Designers handing off specs to developers need accurate hex-to-RGB conversion to ensure pixel-perfect color matching across all implementation targets.

Color Analysis and Accessibility Checking

WCAG accessibility contrast ratios are calculated using the relative luminance formula, which operates on linearized RGB values. Automated accessibility checkers convert hex color codes to RGB, normalize the values, apply gamma correction, and compute contrast ratios. Checking whether a #6B7280 text color on a #FFFFFF background meets the 4.5:1 WCAG AA contrast requirement requires knowing both colors in RGB form first. Understanding the RGB channels also helps designers intuitively adjust lightness by changing all three channels proportionally.

How It Works

HEX to RGB conversion formula: A hex color is a 6-character string: RRGGBB Each pair of hex digits is an 8-bit value (00–FF = 0–255) Conversion (each pair independently): R = parseInt(RR, 16) G = parseInt(GG, 16) B = parseInt(BB, 16) Example: #FF5733 R = parseInt('FF', 16) = 255 G = parseInt('57', 16) = 87 B = parseInt('33', 16) = 51 Result: rgb(255, 87, 51) Shorthand 3-digit hex expansion first: #F53 → #FF5533 before conversion Each digit doubled: F→FF, 5→55, 3→33 For rgba() transparency: rgba(R, G, B, alpha) where alpha is 0.0 (transparent) to 1.0 (opaque) Example: rgba(255, 87, 51, 0.5) = 50% transparent version of #FF5733

Frequently Asked Questions

What is the difference between HEX and RGB color formats?
Both represent the same color using Red, Green, and Blue channels. HEX encodes the values as a base-16 hexadecimal string (#RRGGBB) compact for HTML and CSS. RGB uses decimal numbers (0–255) in the format rgb(R, G, B), which is more readable for humans understanding exact channel intensities and required by some APIs, canvas drawing functions, and image processing libraries.
Why does a hex code start with #?
The # symbol is a CSS convention indicating what follows is a hexadecimal color value. The hex digits themselves are RRGGBB — the # is not part of the color encoding, just a prefix that tells parsers the color is in hex format. In some contexts (image libraries, JSON color values, Android color resources) the # is omitted or replaced with 0x.
What hex codes represent pure primary and achromatic colors?
Pure Red: #FF0000 (rgb 255,0,0). Pure Green: #00FF00 (rgb 0,255,0). Pure Blue: #0000FF (rgb 0,0,255). White: #FFFFFF (rgb 255,255,255). Black: #000000 (rgb 0,0,0). Medium gray: #808080 (rgb 128,128,128). Equal R, G, and B values always produce a shade of gray.
Can I convert hex to RGBA with transparency?
Yes. Convert the hex code to its R, G, B values, then add an alpha (opacity) parameter: rgba(R, G, B, alpha). Alpha ranges from 0.0 (fully transparent) to 1.0 (fully opaque). Some tools support an 8-character hex format #RRGGBBAA where the last two characters represent opacity (00=transparent, FF=opaque). #FF573380 is equivalent to rgba(255, 87, 51, 0.5).
Why do some hex codes have only 3 characters?
Three-character hex codes (#RGB) are shorthand where each digit is doubled: #F53 = #FF5533. This shorthand only works when both digits of each channel are identical (e.g. #CC3388 can be written #C38). Three-character codes are valid CSS but describe a more limited color space (4,096 colors vs 16.7 million for 6-character codes). Most modern design work uses full 6-character codes for precision.

Related Tools

Explore other tools in this category.

Looking for something else?