RGB to Hex Converter
Drag the sliders or type 0–255 values. Your hex code updates live.
How to Convert RGB to Hex — And Why Every Designer Needs to Know This
Every color you see on a screen is defined by three numbers: how much red, how much green, and how much blue. That's the RGB model. But when you open your CSS file or drop a color into a design tool, you're often greeted with a strange six-character string like #3B82F6 instead. This is the hexadecimal — or hex — color code, and understanding how to move between these two formats is one of the most practical skills in web design and front-end development.
This guide walks you through exactly how the conversion works, why it matters, and how to use our tool to get it done in seconds.
What Is the RGB Color Model?
RGB stands for Red, Green, Blue. Your monitor, phone screen, and television all mix these three primary colors of light to produce every color you see. Each channel holds a value from 0 to 255, where 0 means none of that color and 255 means full intensity.
When all three are at 0, you get pure black: rgb(0, 0, 0). When all three are at 255, you get pure white: rgb(255, 255, 255). A vivid red is rgb(255, 0, 0) — full red, no green, no blue. This additive mixing system is why RGB is described as an "additive" color model: you're adding light.
The combination space is massive. With 256 possible values per channel and three channels, you get 256 × 256 × 256 = 16,777,216 distinct colors. That's over 16 million shades from a single model.
What Is a Hex Color Code?
A hex color code is simply a different way of writing the same RGB information. Instead of decimal numbers (base 10), it uses hexadecimal (base 16). In hex, the digits run 0–9 and then A–F, so after 9 comes A (=10), B (=11), up to F (=15).
Each channel gets exactly two hex digits, allowing values from 00 (decimal 0) to FF (decimal 255). The three channels are concatenated with a # prefix: #RRGGBB. So rgb(255, 165, 0) becomes #FFA500 — that's FF for red (255), A5 for green (165), and 00 for blue (0). Orange.
Hex codes are compact, widely supported in HTML and CSS, and universally recognized across every design tool on the planet — from Figma to Photoshop to VS Code.
The Step-by-Step Conversion Process
Converting RGB to hex by hand is a matter of dividing each value into its base-16 components. Let's walk through an example with rgb(72, 199, 142) — a medium teal-green.
Step 1 — Red channel: 72
Divide 72 by 16: quotient 4, remainder 8. So 72 in hex is 48. First two digits: 48.
Step 2 — Green channel: 199
Divide 199 by 16: quotient 12 (=C in hex), remainder 7. So 199 is C7. Next two digits: C7.
Step 3 — Blue channel: 142
Divide 142 by 16: quotient 8, remainder 14 (=E in hex). So 142 is 8E. Final two digits: 8E.
Result: #48C78E. That's a clean, professional mint green you'll find in a lot of modern UI frameworks.
The math isn't hard, but it gets tedious fast — especially when you're iterating through dozens of brand colors in a design handoff. That's exactly what tools like this one are for.
Using the RGB to Hex Converter Tool
Our converter gives you two ways to input color values. You can drag the sliders for an intuitive visual approach — slide the red channel right and watch warm tones emerge in real time. Or, if you already know the exact numbers (say, from a brand guide or a design spec), type them directly into the input fields on the right of each row.
The sliders are color-aware: the red slider's gradient shifts based on your current green and blue values, so you always see exactly what increasing or decreasing that channel does to the final color. The preview chip — the square box in the result area — updates live so you can make perceptual judgments, not just numerical ones.
Once you land on the color you want, hit the Copy button. It copies the full hex code (including the # symbol) directly to your clipboard, ready to paste into CSS, Figma, Canva, or anywhere else. The button briefly turns green to confirm the copy was successful.
Below the main result, the tool also shows you the same color in HSL (hue, saturation, lightness), the CSS rgb() function format, the raw decimal integer, and the full 24-bit binary representation. These extra formats are especially handy when you need to cross-reference values or work in environments that prefer a different notation.
When You'll Actually Use This
Design handoffs: Designers often work in tools that export RGB values from color pickers. Developers need hex for CSS. This converter bridges that gap in two seconds flat.
Copying colors from screenshots: Use your OS's color picker tool (Digital Color Meter on macOS, PowerToys Color Picker on Windows) to sample a color from anywhere on screen — it'll give you RGB. Convert to hex here.
Theming and branding: When building a design system or configuring a theme file, you'll frequently need the same color in multiple formats. Having HSL alongside hex in one view saves you from opening three different tabs.
Accessibility checking: Color contrast tools often accept hex input. Convert your foreground and background colors here first, then paste into a contrast checker to verify your design meets WCAG standards.
Canvas and WebGL work: Some drawing APIs want normalized float values (0.0 to 1.0) rather than integers. Just divide each RGB value by 255 — the tool's decimal and binary displays help you reason about the underlying bit structure if you're doing low-level graphics work.
Common Mistakes to Avoid
The most frequent mistake is entering values above 255. RGB channels are 8-bit — they max out at 255. If a tool gave you values like "310, 50, 200", something went wrong upstream. Our converter automatically clamps all inputs to the valid 0–255 range.
Another common slip is confusing the shorthand hex format. Some colors can be written with three digits instead of six — #F00 instead of #FF0000. This shorthand only works when both digits in each channel are identical. Our tool always outputs the full six-digit form, which is universally supported and unambiguous.
Finally, remember that hex codes are case-insensitive. #ff0000 and #FF0000 are the same color. Our tool outputs uppercase for readability, but you can use either form in your code without any difference in behavior.
A Note on Color Spaces
RGB and hex both live in the sRGB color space — the standard for screens and the web. It's worth knowing that modern CSS is expanding beyond sRGB with Display P3, Oklch, and other wide-gamut formats. But for the overwhelming majority of web projects and tool integrations today, RGB-to-hex conversion covers everything you need. The 16.7 million colors in sRGB are more than enough for professional-grade web and app design.
Use the sliders, find your color, and copy that hex code. It's one of those micro-skills that you'll use hundreds of times across a design career — and with the right tool, it takes under three seconds every time.