Convert RGB to HEX
Converting Red, Green, Blue (RGB) to hexadecimal (HEX) is a precise, rule-based operation — both formats describe the same color with different numbers. Whether you are tuning a CSS custom property, matching a brand color across design tools, or preparing values for print, this page gives you an interactive converter, the exact RGB → HEX method, a worked example, a quick-reference table and the details that matter (rounding, gamut and print caveats).
From
To
—
—
—
Live preview
How to convert RGB to HEX
Take this real example — the color firebrick(#c2410c):
rgb(194, 65, 12) → #c2410c
- Round each channel to a whole number from 0 to 255.
- Convert each channel to hexadecimal and pad to two digits (e.g. 12 → 0C).
- Concatenate with a leading #: #RRGGBB.
hex(channel) = two base-16 digits of round(channel)
RGB to HEX conversion table
| Color | RGB | HEX |
|---|---|---|
| White | rgb(255, 255, 255) | #ffffff |
| Black | rgb(0, 0, 0) | #000000 |
| Red | rgb(255, 0, 0) | #ff0000 |
| Lime | rgb(0, 255, 0) | #00ff00 |
| Blue | rgb(0, 0, 255) | #0000ff |
| VersatilBox accent | rgb(194, 65, 12) | #c2410c |
| Tailwind blue-500 | rgb(59, 130, 246) | #3b82f6 |
| Tailwind emerald-500 | rgb(16, 185, 129) | #10b981 |
About these formats
RGB (Red, Green, Blue). RGB is the additive model screens use: every color is a mix of red, green and blue light from 0 to 255 per channel. It is the numeric base all on-screen conversions pass through.
HEX (hexadecimal). HEX is the web's native notation: a # followed by two digits per channel in base 16 (00–FF). Compact, unambiguous and supported everywhere, from CSS to design tools.
Frequently asked questions
How do I convert RGB to HEX?
Round each channel to a whole number from 0 to 255. Convert each channel to hexadecimal and pad to two digits (e.g. 12 → 0C). Concatenate with a leading #: #RRGGBB. The converter above does it instantly, including the reverse direction.
What is RGB?
RGB — Red, Green, Blue — is the additive model screens use: every color is a mix of red, green and blue light from 0 to 255 per channel. It is the numeric base all on-screen conversions pass through.
What is HEX used for?
HEX (hexadecimal) is the web's native notation: a # followed by two digits per channel in base 16 (00–FF). Compact, unambiguous and supported everywhere, from CSS to design tools.
Is the RGB → HEX conversion exact?
Yes. The formulas are deterministic and both formats store the same information for on-screen color; values are rounded only for display.
Why does the HEX value look different in other tools?
Small differences come from rounding (how many decimals are kept) and from out-of-gamut handling. This site follows the CSS Color 4 algorithms and shows OKLCH with 3 decimals, the same convention used by browsers and mainstream design tools.