What are RGB and HEX?
RGB gives the same three sRGB channels as decimal numbers from 0 to 255, plus an optional alpha. HEX writes the red, green and blue channels of sRGB as two hexadecimal digits each, from 00 to FF.
Color pickers of screenshots, image editors and browser dev tools often show RGB; brand guides, Figma tokens and CSS variables usually keep HEX.
The color converter below starts from RGB and highlights HEX, next to HWB, LAB, LCH and CSS names.
RGB vs HEX
| RGB | HEX | |
|---|---|---|
| Notation | rgb(255 178 36), rgb(255, 178, 36) | #RRGGBB, #RGB, #RRGGBBAA |
| In CSS | all browsers | all browsers |
| Typical use | code that computes colors, canvas, image libraries | CSS, design handoff, brand guides |
Formula
Write each channel (0–255) as two hexadecimal digits and join them: 255 → FF, 178 → B2 (178 = 11 × 16 + 2), 36 → 24, so rgb(255, 178, 36) is #FFB224. Values below 16 need a leading zero (10 → 0A).
What changes in the conversion
- RGB and HEX 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 RGB to HEX
- Type or paste the RGB value in its line, or pick a color with the color picker.
- Read the HEX line, which updates as you type, and check the preview swatch.
Common colors from RGB to HEX
Converted with the same code as the tool:
| Color | RGB | HEX |
|---|---|---|
| amber (stdlib.tools accent) | rgb(255, 178, 36) | #FFB224 |
| teal | rgb(11, 114, 133) | #0B7285 |
| blue | rgb(59, 130, 246) | #3B82F6 |
| green | rgb(22, 163, 74) | #16A34A |
| red | rgb(220, 38, 38) | #DC2626 |
| mid gray | rgb(128, 128, 128) | #808080 |
| black | rgb(0, 0, 0) | #000000 |
| white | rgb(255, 255, 255) | #FFFFFF |
Frequently asked questions
Is RGB to HEX 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 HEX with transparency?
Add two more digits for alpha: #FFB22480 is the amber at 50% opacity (80 hex = 128 of 255).