HEX to RGB Converter
HEX to RGB splits a hex colour into its three decimal channels. Each pair of hex digits is one channel written in base 16, so #FF8800 is rgb(255 136 0). A four- or eight-digit hex carries a fourth pair for alpha, which comes out as a 0–1 value in rgba(). The conversion is exact in both directions — no colour is lost, because both notations describe the same three bytes.
Enter a colour on the left. This accepts hex with or without the hash, rgb(), hsl(), oklch() and the CSS colour names.
How does HEX to RGB Converter work?
A hex colour is three bytes written in base 16. Each byte is one channel — red, green, blue — and holds a value from 0 to 255, which is exactly two hex digits, because 16² is 256. That is the entire conversion: read two characters, interpret them in base 16.
Reading a hex digit
The digits run 0–9 then a–f, where a is 10 and f is 15. The left digit is the number of sixteens and the right digit is the remainder, so 88 is 8×16 + 8 = 136 and ff is 15×16 + 15 = 255. Case does not matter: #FF8800 and #ff8800 are the same colour, and CSS has never distinguished them.
Three-digit hex, and why it is not a rounding
#f80 is shorthand for #ff8800 — each digit is doubled, not padded with a zero. That matters: doubling maps f to ff = 255, the true maximum, while padding would give f0 = 240 and every shorthand colour would come out slightly dark. The shorthand can only express the 4,096 colours whose channel pairs happen to be doubles, which is why it survives for quick values like #fff and disappears from anything designed.
The fourth pair is alpha
CSS Color 4 added 4- and 8-digit hex, where the last pair is opacity on the same 0–255 scale. #ff880080 is rgb(255 136 0 / 0.5), because 0x80 is 128, and 128/255 is 0.502. The slight imprecision is inherent: alpha in CSS is a fraction and hex can only store 256 steps of it, so a value written as 0.5 in rgba() round-trips through hex as 0.502.
Which syntax to write
Modern CSS separates the channels with spaces and the alpha with a slash — rgb(255 136 0 / 50%) — and rgb() now accepts alpha directly, so rgba() is a legacy alias kept for compatibility. The comma form still works in every browser and will continue to; there is no deprecation and no reason to rewrite a stylesheet over it. Both forms are produced here so you can paste whichever your codebase already uses.
A hex colour
#ff8800
Its RGB channels
rgb(255 136 0) ff → 255 (15 × 16 + 15) 88 → 136 (8 × 16 + 8) 00 → 0 (0 × 16 + 0)
What options and edge cases does HEX to RGB Converter support?
| Parameter | Type | Default | Behaviour & edge cases |
|---|---|---|---|
| #rgb | 3 digits | shorthand | Each digit is doubled: #f80 is #ff8800. Only 4,096 colours can be written this way. |
| #rgba | 4 digits | shorthand | The same doubling, with a fourth digit for alpha. #f808 is #ff880088. |
| #rrggbb | 6 digits | standard | One byte per channel, 0–255 each. 16.7 million colours. |
| #rrggbbaa | 8 digits | CSS Color 4 | Alpha as a fourth byte. Supported everywhere current; falls back to opaque in very old browsers rather than being ignored. |
| Case | — | ignored | #FF8800 and #ff8800 are identical. Lower case is the common convention. |
| rgb(r g b) | modern | spaces | The current syntax. Alpha goes after a slash: rgb(255 136 0 / 50%). |
| rgba(r,g,b,a) | legacy | commas | Still valid everywhere and not deprecated. rgb() and rgba() are now the same function. |
| Percentages | 0–100% | allowed | rgb(100% 53.3% 0%) is the same colour. Percentages resolve against 255, not 100. |
Frequently asked questions
How do I convert hex to RGB by hand?
Split the six digits into three pairs, then read each pair as base 16: the left digit is how many sixteens, the right is the remainder. So 88 is 8×16 + 8 = 136. The letters continue the count — a is 10, b is 11, up to f which is 15 — so ff is 15×16 + 15 = 255. Three pairs, three numbers, and that is the whole conversion.
Is #f80 the same as #ff8800?
Yes. Three-digit hex doubles each digit rather than padding it with a zero, so #f80 expands to #ff8800. The doubling is what lets #fff mean pure white; if it padded instead, #fff would be #f0f0f0 and every shorthand would be slightly dark.
How does alpha work in an 8-digit hex?
The last two digits are opacity on the same 0–255 scale as the colour channels, so #ff880080 is 0x80 = 128, which is 128/255 = 0.502 alpha. Because hex only has 256 steps, an alpha written as 0.5 in rgba() comes back as 0.502 through hex. That difference is invisible on screen and will show up if you compare strings.
Should I use rgb() or rgba()?
rgb() — it takes alpha now, so rgba() is a legacy alias for the same function. Neither is deprecated and both work everywhere, so there is no reason to rewrite existing code. For new code, rgb(255 136 0 / 50%) is the current syntax.
Why does my design tool show different RGB numbers for the same hex?
Almost always a colour profile. Hex is a value in a colour space, and if the document is tagged Display P3 or Adobe RGB rather than sRGB, the same three bytes describe a different colour and the tool may show you the sRGB equivalent instead of the raw numbers. This page treats hex as sRGB, which is what a browser does with it in CSS.
How do I use an RGB value in a CSS custom property?
Store the three channels without the rgb() wrapper — --brand: 240 84 30; — then write color: rgb(var(--brand)) for the solid colour and background: rgb(var(--brand) / 0.12) for a translucent tint of it. One variable then serves the colour and every transparency of it, which is why design systems store channels rather than finished colour strings.
Which related tools should I use next?
- Color ConverterConvert between HEX, RGB, HSL, HSV, OKLCH and CMYK, in both directions at once.
- RGB to HEX ConverterTurn rgb() or rgba() values into a hex colour, in three, six or eight digits.
- HEX to HSL ConverterTurn a hex colour into hue, saturation and lightness, ready to paste into CSS.
- HSL to HEX ConverterTurn hue, saturation and lightness into a hex colour.