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.

Red, green and blue (0–255)
HEX color code

All color formats
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.

RGB color value converted to a hex color codergb(79,70,229)#4F46E5RGB to HEXConverter

How to convert RGB to HEX

  1. 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.
  2. Get the hex code. The HEX color code updates immediately, for example #4F46E5.
  3. 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.

ChannelDecimalDivide by 16Hex pair
Red794 remainder 154F
Green704 remainder 646
Blue22914 remainder 5E5

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:

Decimal01751102128153204238255
Hex001133668099CCEEFF

For example, rgb(255, 204, 0) is #FFCC00, and rgb(51, 51, 51) is #333333.

RGB or HEX: which should you use?

HEXRGB
Example#4F46E5rgb(79, 70, 229)
LengthShort (7 characters)Longer, but easy to read
Transparency8-digit hex: #4F46E580rgba(79, 70, 229, 0.5)
Easy to edit by handHard: values are in base 16Easy: plain numbers 0–255
Typical useCSS, design tokens, brand guidesCSS, 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.