Also available in: Español · Português · Français · العربية
RGB to Hex Converter
Turn red, green and blue values into the exact hex code CSS expects, with a live swatch and one-click copy.
What is an RGB to hex converter?
RGB and hex are two different alphabets for describing the same color. RGB spells it out as three numbers — how much red, green and blue light combine to make the pixel, each running from 0 to 255. Hex compresses those same three numbers into a six-character code, the format CSS, HTML, and most design software expect when you’re styling a button, a background, or text. An RGB to hex converter does the translation for you: type in the RGB values and it hands back the matching hex code, instantly and without rounding.
This comes up constantly when tools speak different dialects. A color picker or an image editor’s eyedropper will often hand you RGB — three plain numbers, or a CSS rgb() string — while the stylesheet you’re editing wants a hex code like #4093E6. Rather than doing the base-16 math by hand, you paste or type the RGB value in and read off the hex code, along with the color’s rgb() and hsl() equivalents and its closest named match, so you can move between formats without leaving the page.
How to convert RGB to hex
- Enter the RGB value. Type it into the text field in whatever form you have it — rgb(64, 147, 230), plain 64, 147, 230, space-separated 64 147 230, percentages like rgb(25%, 58%, 90%), or with an alpha channel such as rgb(64 147 230 / 50%).
- Fine-tune with the R, G and B fields. The three number fields below stay in sync with the text field, so you can nudge an individual channel up or down and watch the RGB text and the result update together.
- Copy the hex code. The hex value appears large above a live swatch, with a one-click copy button. Below it you’ll find the same color as rgb() and hsl(), a chip naming the closest of 220 named colors — which links through to that color’s shade page — and a link to the full color picker.
How the conversion works
Hex and RGB describe exactly the same value in two different number bases. Each RGB channel is a number from 0 to 255; each hex channel is a pair of digits from 00 to FF, which is the same range written in base 16 instead of base 10. Converting from RGB to hex is just re-expressing 64 as 40, 147 as 93, and 230 as E6 — no rounding, no approximation, nothing lost. That’s different from the hsl() line shown alongside it, which gets rounded to whole numbers to stay readable.
Two details are worth knowing. If your RGB value includes an alpha channel, it gets folded into the hex output as an extra pair of digits — but alpha is the one place where rounding shows up, since a decimal opacity like 0.5 has to become a whole number of 256ths (0x80, which is 128/255, not an exact half). And hex and RGB both describe standard sRGB colors; a wide-gamut color from Display P3 or similar can’t be written as either format — CSS handles those with functions like color(display-p3 ...) instead.
Why is it free?
The whole conversion happens in your browser — your RGB values never leave the page or touch a server. There’s no account to create, no watermark on the hex code, and no premium tier hiding the copy button or the other formats behind it. It’s a small, fast calculation, and there’s no reason to charge for it.