RGB to HEX Converter
Convert RGB to HEX instantly. Enter red, green and blue values from 0 to 255, or paste an rgb() value, and copy the hex color code.
Paste rgb(), rgba() or values like 79, 70, 229 into the R, G and B fields. Hex, hsl() and oklch() also work.
| HEX | | |
|---|---|---|
| HEX + alpha | | |
| RGB | | |
| RGBA | | |
| HSL | | |
| OKLCH | | |
| Tailwind | |
Convert RGB Color Values to HEX Online
Many design apps, color pickers and APIs give you colors as RGB numbers, while CSS files, brand guides and design tokens usually use hex codes. This RGB to HEX converter turns red, green and blue values into the matching hex color code as you type.
Type the three numbers into the R, G and B fields or paste a complete rgb() value. You also get RGBA, HSL, OKLCH and a Tailwind class for the same color, ready to copy. It runs in your browser and needs no sign-up.
How to convert RGB to HEX
- Enter the RGB values. Type the red, green and blue numbers (0–255) into the R, G and B fields, or paste a value such as
rgb(79, 70, 229)into the RGB color field. - Get the hex code. The HEX color code updates immediately, for example
#4F46E5. - Copy it. Click Copy, or copy another format from the table below it.
How RGB to HEX conversion works
Each RGB channel is a number from 0 to 255. To write it in hex, divide it by 16: the whole number is the first hex digit and the remainder is the second (10 = A, 11 = B, 12 = C, 13 = D, 14 = E, 15 = F). Then join the three pairs in red, green, blue order.
| Channel | Decimal | Divide by 16 | Hex pair |
|---|---|---|---|
| Red | 79 | 4 remainder 15 | 4F |
| Green | 70 | 4 remainder 6 | 46 |
| Blue | 229 | 14 remainder 5 | E5 |
Result: rgb(79, 70, 229) = #4F46E5. Values below 16 get a leading zero, so 9 becomes 09.
Decimal to hex values for each channel
These channel values come up again and again in palettes and web-safe colors:
| Decimal | 0 | 17 | 51 | 102 | 128 | 153 | 204 | 238 | 255 |
|---|---|---|---|---|---|---|---|---|---|
| Hex | 00 | 11 | 33 | 66 | 80 | 99 | CC | EE | FF |
For example, rgb(255, 204, 0) is #FFCC00, and rgb(51, 51, 51) is #333333.
RGB or HEX: which should you use?
| HEX | RGB | |
|---|---|---|
| Example | #4F46E5 | rgb(79, 70, 229) |
| Length | Short (7 characters) | Longer, but easy to read |
| Transparency | 8-digit hex: #4F46E580 | rgba(79, 70, 229, 0.5) |
| Easy to edit by hand | Hard: values are in base 16 | Easy: plain numbers 0–255 |
| Typical use | CSS, design tokens, brand guides | CSS, JavaScript, canvas, design APIs |
Both formats describe the same sRGB colors, so you can switch at any time without losing accuracy.
Frequently Asked Questions
Common questions about converting RGB values to hex color codes.
Convert each channel (0–255) to a two-digit hex number and join them: rgb(79, 70, 229) becomes 4F, 46 and E5, so the hex code is #4F46E5. The converter above does this as you type.
rgb(255, 255, 255) is white, #FFFFFF. rgb(0, 0, 0) is black, #000000.
Use an 8-digit hex code: the alpha value is multiplied by 255 and added as the last pair. rgba(79, 70, 229, 0.5) becomes #4F46E580. The RGBA to HEX converter also gives you a solid 6-digit version.
Paste them as rgb(100%, 50%, 0%) and they are converted automatically. 100% equals 255.
Each RGB channel stores 8 bits, so it can only hold 0 to 255. Larger numbers are capped at 255 and negative numbers at 0.
Hex codes are not case-sensitive, so #4F46E5 and #4f46e5 are the same color. The converter shows upper case; the Tailwind class uses lower case.
Yes. Paste a hex code into the field above, or use the HEX to RGB converter.