HEX to RGBA

Turn #RGB, #RRGGBB, or #RRGGBBAA into rgba() for CSS and React. Tune alpha when the hex has 6 digits.

{{ t("hexToRgbaFormatsHint") }}

{{ hexToRgba.message }}

Overview

CSS started with exactly 16 named colors inherited from DOS VGA — `black`, `white`, `red`, and similar. Hexadecimal notation came later, borrowed from the X11 color system on Unix, and was adopted by HTML 3.2 in 1997 through the `color` attribute. For a long time, if you wanted a semi-transparent color on the web, your options were creative and far from elegant: a 1x1 PNG tile repeated as a background, `filter: alpha(opacity=50)` for Internet Explorer, stacked `div` elements with `position: absolute`. The `rgba()` function arrived in CSS2.1 but only became reliably supported across all relevant browsers around 2010 — before that, any transparency effect was an exercise in patience.

Hexadecimal became the lingua franca for design colors because tools like Adobe Photoshop, Illustrator, Sketch, and Figma have always used it as the primary export format. The short `#RGB` notation — where `#F0A` expands to `#FF00AA` — dates back to HTML 3.2. The 4-digit `#RGBA` variant with an alpha channel has never been widely used but exists. The full 8-digit `#RRGGBBAA` format is the newest: it is part of CSS Color Level 4, published around 2017, adding the alpha channel directly to the hex value. Browser support is solid in modern environments, but there are still contexts — HTML emails, inline SVGs, some CSS parsers — that only understand the 3 or 6-digit formats without alpha.

This tool interprets all of those formats — `#RGB`, `#RGBA`, `#RRGGBB`, and `#RRGGBBAA` — and converts them to `rgba()` with an explicit alpha channel. When you use 3 or 6-digit formats, you can apply an additional transparency factor through the slider; with the 8-digit format, the embedded alpha takes priority. One non-obvious practical use: CSS variables with `rgba()` let you override just the alpha channel in JavaScript without having to pass all three RGB values again. Defining `--primary-color: rgba(26, 115, 232, 0.8)` and then changing only the opacity via `style.setProperty` is cleaner than decomposing the hex every time.

Technical deep dive

Common questions summarized

  • What is this tool for?: It runs fully in your browser: useful to validate, format, or convert data in everyday development.
  • Are my inputs sent to a server?: Processing happens locally with JavaScript. We do not store what you paste into the text areas.
  • Can I use this for real production data?: Use at your own risk. For secrets (passwords, tokens), prefer controlled environments and your company policies. And always review the generated contents. Never trust blindly things you see on the internet.

Sample payload to try

  • See also the larger "Code Snippets" sample; paste this excerpt to try locally: Sample — #3b82f6cc

Code Snippets

Code example
#3b82f6cc

Sample

#3b82f6cc

FAQ

What is this tool for?

It runs fully in your browser: useful to validate, format, or convert data in everyday development.

Are my inputs sent to a server?

Processing happens locally with JavaScript. We do not store what you paste into the text areas.

Can I use this for real production data?

Use at your own risk. For secrets (passwords, tokens), prefer controlled environments and your company policies. And always review the generated contents. Never trust blindly things you see on the internet.