How to use Hex to RGB converter
- Type or paste a hex code in the input box. The leading # is optional.
- Watch the preview swatch update. Below it, the table lists the HEX, RGB and HSL values of the same color.
- Not sure of the code? Click the color picker and choose a color by eye, and the field fills in for you.
- Press the copy button to take the rgb() value, for example rgb(79, 51, 232), and paste it into your CSS.
- To go the other way, open the RGB to hex converter linked under the tool.
Features
- Accepts #RGB, #RGBA, #RRGGBB and #RRGGBBAA codes, with or without the # sign
- Shows red, green and blue as whole numbers from 0 to 255
- Reads the last pair of an 8-digit code as alpha and returns rgba()
- Live preview swatch that follows your typing
- HSL value listed next to HEX and RGB
- Built-in color picker for choosing a color visually
Examples
| Input | Result |
|---|---|
| #4F33E8 | rgb(79, 51, 232) — 4F = 79, 33 = 51, E8 = 232. |
| #F33 | rgb(255, 51, 51) — Shorthand: each digit is doubled, so #F33 is #FF3333. |
| #2A3B4C80 | rgba(42, 59, 76, 0.502) — The last pair 80 is 128, and 128 / 255 is about 0.502. |
| #FFFFFF | rgb(255, 255, 255) — White: every channel at its maximum. |
Limitations
- Only hexadecimal input is read here. RGB values go into the RGB to hex converter.
- Named colors such as "red" and formats like CMYK are not accepted.
- Screens and browsers apply their own color management, so the swatch may look slightly different from a printed color.
Learn more
A hex color code writes a color in base 16. Each pair of digits runs from 00 to FF, which is 0 to 255 in decimal, and the pairs stand for red, green and blue in that order. Because each channel fits in one byte, a 6-digit code describes 256 x 256 x 256, or 16,777,216, possible colors.
The 3-digit form is a shortcut from CSS. It doubles every digit, so it can only express colors whose pairs repeat, such as #FFF, #000 or #F33. The 8-digit form, supported by CSS Color Module Level 4, adds a fourth pair for alpha. As a fraction, alpha is the pair's decimal value divided by 255.
Use hex when you are copying colors between stylesheets and design tools, because it is short and widely understood. Use RGB when a library, canvas API or image editor expects separate red, green and blue numbers, or when you want to adjust opacity with rgba(). HSL is handy for making a color lighter or darker without changing its hue.
Frequently asked questions
How do I convert hex to RGB by hand?
Split the code into three pairs and convert each from base 16 to base 10. For #4F33E8, 4F is 4 x 16 + 15 = 79, 33 is 51 and E8 is 14 x 16 + 8 = 232.
What does a 3-digit hex code like #F33 mean?
Each digit is repeated, so #F33 equals #FF3333, which is rgb(255, 51, 51). Shorthand only works when both digits of each pair are the same.
What is the last pair in an 8-digit hex code?
It is the alpha (opacity) channel. 00 is fully transparent and FF is fully opaque, so #2A3B4C80 is about 50 % opaque.
Can I convert a hex color to RGB for CSS?
Yes. Copy the result and use it directly, for example color: rgb(79, 51, 232). Modern CSS also accepts the hex code itself, so the conversion is mostly for tools that need separate channels.
Does the tool also give HSL?
Yes. The HSL value appears in the table under the swatch, next to the HEX and RGB forms of the same color.
Sources
Last reviewed: September 29, 2026