RGB to Hex Converter
Enter red, green, and blue values (0–255) to get the matching 6-digit hex code — instantly, with no signup.
What Is the RGB Color Model?
RGB stands for red, green, and blue — the three colors of light that screens mix together to produce every color you see on a monitor, phone, or TV. Each channel ranges from 0 (none of that color) to 255 (maximum intensity), giving 256 × 256 × 256, or roughly 16.7 million, possible combinations. RGB is an additive color model: start with black (0, 0, 0) and add light to get brighter colors, ending at white (255, 255, 255) when all three channels are maxed out.
You'll most often see RGB values coming out of a color picker, a photo-editing tool's eyedropper, or a design app's color panel — most of those tools default to showing RGB because it maps directly onto how the underlying pixel data is stored.
How the Conversion Works
A hex code packs the same three RGB numbers into base 16 instead of base 10, using two digits per channel (00 to FF). Converting is a straightforward decimal-to-hex conversion applied three times:
R: 99 ÷ 16 = 6 remainder 3 → 63
G: 102 ÷ 16 = 6 remainder 6 → 66
B: 241 ÷ 16 = 15 remainder 1 → F1
rgb(99, 102, 241) → #6366F1
You never need to do this by hand — the converter above runs the same math live as you type — but knowing the mechanics explains why hex codes always come out to exactly six characters, and why each pair of characters corresponds to exactly one RGB channel.
Common RGB to Hex Conversions
RGB and hex values for 20 named colors from Colortion's library — click a name for the full color page, including pairing suggestions and palettes that use it.
| Color | RGB | Hex |
|---|---|---|
| Sage Green | 135, 168, 120 | #87A878 |
| Dusty Rose | 196, 132, 122 | #C4847A |
| Terracotta | 196, 106, 58 | #C46A3A |
| Navy Blue | 27, 42, 74 | #1B2A4A |
| Lavender | 184, 154, 196 | #B89AC4 |
| Coral | 255, 107, 107 | #FF6B6B |
| Forest Green | 45, 106, 79 | #2D6A4F |
| Burgundy | 128, 0, 32 | #800020 |
| Teal | 20, 184, 166 | #14B8A6 |
| Mustard Yellow | 212, 160, 23 | #D4A017 |
| Blush Pink | 249, 198, 198 | #F9C6C6 |
| Slate Blue | 106, 154, 184 | #6A9AB8 |
| Olive Green | 107, 124, 60 | #6B7C3C |
| Burnt Orange | 204, 85, 0 | #CC5500 |
| Mauve | 168, 126, 168 | #A87EA8 |
| Cobalt Blue | 0, 71, 171 | #0047AB |
| Emerald Green | 80, 200, 120 | #50C878 |
| Rose Gold | 183, 110, 121 | #B76E79 |
| Champagne | 247, 231, 206 | #F7E7CE |
| Periwinkle | 204, 204, 255 | #CCCCFF |
RGB or Hex — Which Should You Use?
Both are equally valid in CSS, so the choice usually comes down to context rather than correctness. Use RGB when you need to control transparency with rgba() (hex has an 8-digit alpha variant too, but it's less commonly supported in older tools), or when a design tool's color picker already gives you RGB sliders and converting adds an unnecessary step. Use hex when you're pasting a color into most design software, sharing a color code with a developer, or working anywhere brevity matters — six characters is faster to read and type than three comma-separated numbers.
Need to go the other direction? Use the Hex to RGB converter instead.
Frequently Asked Questions
How do I convert RGB to hex?
Convert each of the three RGB values (red, green, blue) from decimal (0–255) to a two-digit base-16 number, then join them with a # prefix. For example, rgb(99, 102, 241) becomes #6366F1 because 99 in base 16 is 63, 102 is 66, and 241 is F1.
Why do RGB and hex give the same color two different ways?
They describe the same additive color model — red, green, and blue light mixed together — just in different number bases. RGB uses decimal (base 10, 0–255 per channel) because it matches how humans count; hex uses base 16 because two hex digits map exactly onto one byte (0–255), which is more compact to write and matches how color values are stored in memory.
Can I use RGB values directly in CSS instead of converting to hex?
Yes — CSS accepts both rgb(99, 102, 241) and #6366F1 as equivalent, valid ways to set the same color. Converting to hex is about convenience: hex codes are shorter, easier to paste into design tools, and are what most color-palette resources (including Colortion) display by default.
Is the conversion from RGB to hex lossy?
No. RGB and hex are two exact representations of the same underlying color value — converting between them never loses precision, unlike converting to a format like CMYK, which involves an approximation for print.