How to use RGB to hex converter
- Type the color in the input box, for example rgb(79, 51, 232). Three plain numbers like 79 51 232 work too.
- To include transparency, write rgba(34, 197, 94, 0.5) with alpha as a decimal from 0 to 1.
- Check the preview swatch. The table below lists the HEX, RGB and HSL values of the same color.
- Use the color picker if you would rather choose a color by eye than type numbers.
- Press the copy button and paste the hex code into your stylesheet or design tool.
Features
- Reads rgb(), rgba() or three plain numbers separated by spaces or commas, and also percentages such as 50%
- Returns a 6-digit hex code, or 8 digits when alpha is below 1
- Live preview swatch that follows your typing
- HSL equivalent shown beside HEX and RGB
- Built-in color picker
- Clear error message when a channel is outside 0 to 255
Examples
| Input | Result |
|---|---|
| rgb(79, 51, 232) | #4F33E8 — 79 = 4F, 51 = 33, 232 = E8. |
| rgb(255, 87, 51) | #FF5733 — 255 = FF, 87 = 57, 51 = 33. |
| rgba(79, 51, 232, 0.2) | #4F33E833 — 0.2 x 255 = 51, which is 33 in hex. |
| rgb(0, 0, 0) | #000000 — Black: every channel at zero. |
Limitations
- Each channel must be a whole number from 0 to 255. Values outside that range are rejected with an error message.
- Only RGB and RGBA are read here. Hex input belongs in the hex to RGB converter.
- Named colors such as "red" are not accepted, and channels must be whole numbers.
- Alpha is rounded to the nearest of 256 steps, so some decimals cannot be reproduced exactly.
Learn more
RGB describes a color as three numbers, one for each light channel of a screen: red, green and blue. Each number runs from 0 to 255 because it is stored in one byte. Mixing the three at full strength gives white, and all at zero gives black.
A hex color code is the same information written in base 16. Every byte becomes two digits from 00 to FF, and the three pairs are joined behind a # sign. To convert by hand, divide the number by 16: the quotient is the first digit and the remainder is the second. For 232, the quotient is 14 (E) and the remainder is 8, so the pair is E8.
Hex is the usual choice in CSS and design specs because it is short and easy to copy. RGB is better when you need to change one channel in code or add opacity with rgba(). When transparency is involved, the alpha fraction is multiplied by 255, rounded, and written as a fourth pair. HSL, shown in the table, describes the same color by hue, saturation and lightness instead.
Frequently asked questions
How do I convert RGB to hex?
Turn each of the three numbers into two hexadecimal digits and join them after a #. For rgb(79, 51, 232) that gives 4F, 33 and E8, so the code is #4F33E8.
What is 255 in hex?
255 is FF, the highest value a channel can take. Zero is 00, and 128 is 80.
How do I convert RGB to hex for transparent colors?
Enter rgba() with an alpha from 0 to 1. The tool multiplies alpha by 255 and appends it as a fourth pair, so an alpha of 0.2 adds 33.
Can I type the numbers without rgb() around them?
Yes. Three values like 79 51 232 are accepted, as well as the full rgb(79, 51, 232) form. Percentages such as 50% also work.
Why does the tool say my color is invalid?
A channel is probably above 255 or below 0, or one value is missing. Check that you have three numbers, each between 0 and 255.
Sources
Last reviewed: September 29, 2026