DEVELOPER PRECISION ENGINE

HEX to RGB Converter

Convert HEX color codes to RGB values with alpha channel support.

Red
52
Green
152
Blue
219
Alpha
1

Converted Values

RGBrgb(52, 152, 219)
RGBArgba(52, 152, 219, 1)
HSLhsl(204, 70%, 53%)
HSLAhsla(204, 70%, 53%, 1)

HSL Values

Hue: 204°
Saturation: 70%
Lightness: 53%

How to Use This Tool

1

Enter a HEX color code (with or without # prefix).

Enter a HEX color code (with or without # prefix).

2

Supports 3-digit (#fff), 4-digit with alpha (#fffc), 6-digit (#ffffff), and 8-digit with alpha (#ffffffff)

confirmed via testing, the 4-digit shorthand-with-alpha format works correctly even though it's easy to overlook alongside the more common 3- and 6-digit forms.

Pro Tip

When converting an 8-digit hex code with an alpha channel, remember the alpha byte (the last two hex digits) represents a value from 00 to FF mapped to 0–1 in rgba(), not 0–255 — 80 in hex is 128 in decimal, which converts to roughly 0.5 opacity, not 128% as a naive reading might suggest. This trips up developers reading raw hex-with-alpha values for the first time far more often than the RGB channels themselves. A quick mental anchor worth keeping in mind: 80 hex, C0 hex, and FF hex correspond roughly to 50%, 75%, and 100% opacity respectively, which covers the vast majority of everyday transparency values without needing a calculator each time. It's also worth remembering that 3-digit shorthand hex only ever expands by digit-doubling, not by inserting a zero — #ABC becomes #AABBCC, never #0A0B0C — a distinction that matters if you're ever writing conversion logic yourself instead of relying on a tool to handle the expansion correctly every time.

About This Tool

When to Use

  • Converting a hex color from a Figma or Sketch design file into RGB values for a CSS rgba() transparency declaration
  • Translating a brand's official hex color code into RGB for a JavaScript color-manipulation library that expects RGB input arrays
  • Converting an 8-digit hex-with-alpha code into rgba() syntax for a semi-transparent overlay layered on top of a hero image

Key Details

A HEX-to-RGB converter translates 3- or 6-digit hexadecimal color codes (like #3B82F6) into their red, green, blue component values (59, 130, 246), with optional alpha channel support for 8-digit hex ...

Worked example

Converting #3B82F6 produces rgb(59, 130, 246) — each pair of hex digits (3B, 82, F6) converts to its decimal equivalent, giving the red, green, and blue channel values respectively. Adding an alpha suffix like #3B82F680 converts to rgba(59, 130, 246, 0.5) for roughly 50% opacity, which is exactly what's needed when layering that same brand blue as a translucent overlay. The same logic extends to a 3-digit shorthand: converting #3bf expands each digit before converting, producing rgb(51, 187, 255) rather than any smaller or truncated value a naive single-digit reading might otherwise suggest. This same shorthand-expansion rule applies identically to any 3-digit code entered anywhere in the tool, so a quick sanity check against the expanded 6-digit equivalent is always available if a result ever looks unexpected.

HEX to RGB Converter FAQ

What is the difference between HEX and RGB?

HEX is a hexadecimal representation of colors (e.g., #FF5733) while RGB uses decimal values (e.g., rgb(255, 87, 51)). Both represent the same color — just different notation. HEX is more compact and common in web design; RGB is more intuitive for programmatic color manipulation.

How do I read a hex color code?

A 6-digit hex code has 3 pairs: #RRGGBB. First pair is Red (00-FF), second is Green, third is Blue. #FF0000 is pure red, #00FF00 is pure green, #0000FF is pure blue. #FFFFFF is white, #000000 is black. The values range from 00 (0) to FF (255) per channel.

What is the 3-digit hex format, and is there a 4-digit version too?

3-digit hex (#RGB) is a shorthand where each digit is doubled to form the 6-digit equivalent. #F00 = #FF0000 (red), #FFF = #FFFFFF (white). This is useful for saving characters in CSS but gives fewer color choices (4096 vs 16.7 million). There's also a 4-digit variant (#RGBA) that adds a shorthand alpha digit the same way — #F00C expands to #FF0000CC — confirmed supported by this tool, though it's easy to overlook next to the more common 3- and 6-digit forms.

What does the alpha channel do in 8-digit hex?

8-digit hex (#RRGGBBAA) adds a fourth pair for alpha/opacity. AA ranges from 00 (fully transparent) to FF (fully opaque). #FF0000FF is opaque red, #FF000080 is semi-transparent red at 50% opacity.

How are HSL values calculated from HEX?

HSL (Hue, Saturation, Lightness) is calculated from RGB using the standard algorithm: Hue is the angle on the color wheel (0°=red, 120°=green, 240°=blue), Saturation is the intensity (0%=gray, 100%=full color), Lightness is brightness (0%=black, 100%=white).

What's the difference between hex #fff and rgb(255,255,255)?

They are the same color — just different notation. Both represent pure white (maximum red, green, and blue). Hex is more compact for CSS (6 characters vs 20+ for rgb), while RGB is more readable for programmatic manipulation. The CSS spec also supports modern syntax: rgb(255 255 255) with spaces instead of commas.

Master Your Entire Toolkit

Access 500+ specialized calculators and tools designed for precision. No sign-up required, 100% free.

Built and reviewed by the Toolzip Team · Based on W3C CSS Color Specification