InfyCalculator
💻

Hex to RGB CSS Converter

Turn a hex color code into ready-to-paste CSS rgb() and rgba() values, with each channel in decimal — 3-digit shorthand supported.

Hex color
Opacity
Loading calculator…

How it works

R = hex[0:2]₁₆ · G = hex[2:4]₁₆ · B = hex[4:6]₁₆ (each 0–255)

A hex color packs three 8-bit channels into six hexadecimal digits: the first pair is red, the second green, the third blue, each running 00–FF (0–255 in decimal). Three-digit shorthand like #39f expands by doubling every digit (#3399ff). Converting to rgb() is just reading each pair as a base-16 number, which is what a browser does internally — the two notations describe the exact same color.

Worked example

#3498db splits into 34, 98 and db. 34₁₆ = 52, 98₁₆ = 152, db₁₆ = 219, so the CSS value is rgb(52, 152, 219). At 60% opacity that becomes rgba(52, 152, 219, 0.60).

Sources: CSS Color Module — sRGB

Frequently asked questions

What does the shorthand #39f mean?

Each digit is doubled: #39f expands to #3399ff, i.e. rgb(51, 153, 255). Shorthand only works when all three channels happen to have matching digit pairs.

How do I add transparency?

rgb() has no alpha, so use rgba() with a fourth value from 0 (invisible) to 1 (opaque). An 80% opacity is written as the decimal 0.8. Modern CSS also allows #RRGGBBAA hex with a two-digit alpha suffix.

Is rgb() slower than a hex code?

No — browsers parse both to the same 24-bit color, so there is zero rendering difference. Pick whichever is easier to read or generate in your workflow.

Related calculators

This calculator is for educational purposes. Double-check important results before acting on them.