HEX to RGBA Color Tool
Parse HEX, rgb(), rgba(), hsl(), hsla(), or any named CSS color — and get HEX, RGB, RGBA, and HSL with a live preview and WCAG contrast check.
Color Input
Converted Color Formats
HEX
#3498db
RGB
rgb(52, 152, 219)
RGBA (with alpha slider)
rgba(52, 152, 219, 1)
HSL
hsl(204, 70%, 53%)
Color Math Behind the Converter
How hex channels, RGBA alpha, HSL conversion, and WCAG luminance actually work — explained with the exact formulas.
Hex, RGB & the Alpha Channel
Every hex color packs three 8-bit channels:
#RRGGBB
splits into red, green, and blue values from 0–255. A fourth
pair
#RRGGBBAA
holds alpha, written as 00–FF and read as
alpha = AA/255. The three-digit shorthand
#RGB
doubles each digit —
#39c
equals
#3399cc. RGBA stores the same channels as decimal with an alpha from
0–1:
rgba(51, 153, 204, 0.8). The two formats are interchangeable; the converter simply
re-emits the same numeric channels in each syntax.
HSL Conversion & WCAG Contrast
HSL expresses the same color as hue (0–360°), saturation, and
lightness percentages, converted to RGB with a standard
piecewise formula. Contrast follows the WCAG
relative-luminance model: each 0–255 channel is linearized
with
L(c) = (c≤0.03928 ? c/12.92 : ((c+0.055)/1.055)^2.4), then
L = 0.2126·R + 0.7152·G + 0.0722·B, and contrast is
(L₁+0.05)/(L₂+0.05)
for the lighter and darker of the two colors. The tool reports
black text (luminance 0) and white text (luminance 1) against
your color composited over white.
Troubleshooting & Edge-Case Failure Points
- Bad hex length: #RGB (3), #RGBA (4), #RRGGBB (6), and #RRGGBBAA (8) are valid; anything else, like #RRGGB, is rejected.
- Non-hex characters: values like #GGH are refused; the tool accepts only 0–9 and A–F in hex notation.
- Alpha units: rgb() with a fourth value is actually rgba(); alpha must be 0–1 (or 0–100%), never 0–255.
- HSL percentages: saturation and lightness require the "%" sign; a bare 50 is ambiguous and rejected.
- Named-color collisions: the autocomplete list is the standard CSS set, so typing "rebeccapurple" or "tomato" resolves to its canonical hex.
Step-by-Step Instructions
- Type or paste any CSS color — #RGB, #RRGGBB, #RRGGBBAA, rgb(), rgba(), hsl(), hsla(), or a named color like "tomato".
- Drag the alpha slider from 0–100% to adjust opacity; all outputs update live.
- Check the swatch (the checkerboard reveals transparency) and the WCAG contrast ratios against black and white text.
- Copy the HEX, RGB, RGBA, or HSL string you need with the matching Copy button.
- Use the named-color autocomplete to quickly jump to any of the ~148 standard CSS colors.
Informative Guides & Helper Articles
Ultimate Guide to HEX to RGBA Color Tool
Hex, RGB, RGBA, and HSL explained — how alpha works, how channels map, and why consistent formats matter in CSS.
Read Article →Best Practices for HEX to RGBA Color Tool
Accessibility contrast targets, choosing formats per use case, and using alpha responsibly in UI design.
Read Article →Common Errors in HEX to RGBA Color Tool
Wrong hex length, alpha as 0–255 instead of 0–1, missing % in HSL, and forgiving-browser parsing traps.
Read Article →Top Optimization Tips for Color Conversion
Shrink CSS bytes with short hex, build token palettes, and streamline your contrast-review workflow.
Read Article →Future Trends in Color & Conversion
OKLCH, HDR and wide-gamut displays, CSS color-mix(), and design-token ecosystems are redefining color workflows.
Read Article →How to Use the Hex ⇄ RGBA Converter
Converts between hex color codes and rgba() values — including the alpha channel — with instant color preview.
- Paste a hex (#RRGGBB, #RGB shorthand, or 8-digit #RRGGBBAA) or an rgba() string.
- Read the conversion both ways with the alpha mapped (00 = transparent, FF = opaque).
- Use the preview swatch to confirm before pasting into CSS.
Hexadecimal Colors Decoded
Six hex digits are three bytes: #1A2B3C means R=0x1A (26), G=0x2B (43), B=0x3C (60) — giving 16,777,216 addressable colors (256³). The 3-digit shorthand #ABC expands to #AABBCC; the 8-digit form (and rgba()) adds alpha where 00–FF maps to 0–1 (0x80 ≈ 0.502, the common gotcha — "80" is not 50% but half of 255 ≈ 50.2%). CSS accepts both spellings with identical results; hex is the design-tool native, rgba() wins when you compute alpha in code. History note: the 24-bit RGB standard descends from 1980s display hardware, which is why "true color" froze at 16.7M — more than the ~10M colors human vision discriminates.
Hex ⇄ RGBA Converter FAQ
What does each hex pair mean?
Two hex digits = one byte 0-255 per channel: #1A2B3C is red 26, green 43, blue 60.
Is 8-digit hex the same as rgba()?
Yes - #RRGGBBAA maps alpha 00 (transparent) to FF (opaque); 0x80 is ~50.2% opacity, not exactly half.
Why 16.7 million colors?
256 values per channel cubed (256^3) - a legacy of 24-bit display hardware, already more than human vision distinguishes.