What are HEX and RGB?
HEX writes the red, green and blue channels of sRGB as two hexadecimal digits each, from 00 to FF. RGB gives the same three sRGB channels as decimal numbers from 0 to 255, plus an optional alpha.
Designers hand over HEX; code that animates, blends or sets transparency (rgb(… / 50%), canvas, Android) needs the three numbers.
The color converter below starts from HEX and highlights RGB, next to HWB, LAB, LCH and CSS names.
HEX vs RGB
| HEX | RGB | |
|---|---|---|
| Notation | #RRGGBB, #RGB, #RRGGBBAA | rgb(255 178 36), rgb(255, 178, 36) |
| In CSS | all browsers | all browsers |
| Typical use | CSS, design handoff, brand guides | code that computes colors, canvas, image libraries |
Formula
Split the six digits in pairs and read each pair as a base-16 number: FF = 15 × 16 + 15 = 255, B2 = 11 × 16 + 2 = 178, 24 = 2 × 16 + 4 = 36, so #FFB224 is rgb(255, 178, 36). A three-digit HEX doubles each digit (#F80 = #FF8800).
What changes in the conversion
- HEX and RGB describe the same sRGB color; the only difference is rounding of the last digit.
- Transparency (alpha) is kept:
#RRGGBBAA,rgb(… / 0.5),hsl(… / 50%)andoklch(… / 0.5)all carry it.
How to convert HEX to RGB
- Type or paste the HEX value in its line, or pick a color with the color picker.
- Read the RGB line, which updates as you type, and check the preview swatch.
Common colors from HEX to RGB
Converted with the same code as the tool:
| Color | HEX | RGB |
|---|---|---|
| amber (stdlib.tools accent) | #FFB224 | rgb(255, 178, 36) |
| teal | #0B7285 | rgb(11, 114, 133) |
| blue | #3B82F6 | rgb(59, 130, 246) |
| green | #16A34A | rgb(22, 163, 74) |
| red | #DC2626 | rgb(220, 38, 38) |
| mid gray | #808080 | rgb(128, 128, 128) |
| black | #000000 | rgb(0, 0, 0) |
| white | #FFFFFF | rgb(255, 255, 255) |
Frequently asked questions
Is HEX to RGB exact?
Yes, up to rounding: both describe the same 8-bit sRGB color, so converting back gives the same value.
Which format should I use in CSS?
HEX and rgb() work everywhere; hsl() is handy for shades written by hand; oklch() gives even lightness steps and wide-gamut colors in current browsers.
How do I write RGB with transparency?
Use a slash: rgb(255 178 36 / 50%), or the older rgba(255, 178, 36, 0.5); both mean 50% opacity.