Convert RGB channel values to a hex color code. Each channel from 0β255 becomes two base-16 digits β 30, 144, 255 becomes #1e90ff β and the tool accepts rgb() syntax or bare comma-separated numbers, shows the conversion working, and copies the result in one click.
Generated locally in your browser β your colors, settings and code never leave this page.
From channel numbers to a six-digit code
RGB gives a color as three decimal numbers, 0–255 per channel. Hex packs those same numbers into base 16, two digits each, producing the familiar #-prefixed code. Because 16² is exactly 256, every channel value has a unique two-digit spelling and nothing is rounded — rgb(255, 99, 71) and #ff6347 are the same 24 bits.
To convert a channel by hand, divide by 16: the quotient is the first digit, the remainder the second, with 10–15 written a–f.
Worked example: rgb(255, 99, 71)
Tomato red, channel by channel:
255 Γ· 16 = 15 r 15 β f f β ff 99 Γ· 16 = 6 r 3 β 6 3 β 63 71 Γ· 16 = 4 r 7 β 4 7 β 47 rgb(255, 99, 71) = #ff6347
The maximum channel, 255, becomes ff — the signature of a fully saturated channel that you quickly learn to read at a glance. A channel of 0 becomes 00, never a single 0: hex pairs are always two digits, and dropping the leading zero is the most common hand-conversion bug.
Why ship hex at all?
Compatibility and compactness. Hex works in CSS since the beginning, in every design tool’s color field, in SVG attributes, email HTML, terminal themes and countless config formats that never learned rgb() syntax. Seven characters, no spaces, no commas — nothing for a parser to mis-split. When a value must travel between systems, hex is the travel format.
Keep RGB when humans need to reason about the channels or when alpha is in play with the modern slash syntax; this page’s output includes an uppercase variant for codebases that standardize on #FF6347 style.
Edge cases the tool handles for you
Fractional channels (legal in CSS, e.g. from computed styles) round to the nearest integer before encoding. Percentage channels scale by 2.55 first. Out-of-range values are rejected with a message rather than clamped silently — a 300 in a channel is a bug upstream, and hiding it helps nobody.
How to use the RGB to HEX Converter
- Type the RGB color – rgb(30, 144, 255), the modern space syntax, or bare numbers like 30 144 255.
- The result updates live as you type – no convert button needed.
- Check the working: each channel converted to two base-16 digits.
- Copy the value with the copy button, or switch the output format dropdown for other export shapes.
- Share the exact result: the page URL updates with your input, so the link reproduces it.
Frequently asked questions
How do I convert RGB to HEX by hand?
Divide each channel by 16: the quotient is the first hex digit, the remainder the second. For 144: 144Γ·16 = 9 remainder 0, so 90. Digits above nine become letters (10=a β¦ 15=f). Chain the three pairs and prefix #.
Why does my RGB value 144 become 90 in hex?
Because hex digits carry 16 values, not 10. 144 decimal is 9Γ16 + 0, written 90 in base 16 – the "90" is not ninety. Reading hex as decimal is the single most common mistake when hand-converting colors.
What happens with RGB values above 255 or below 0?
The converter rejects them with a clear error instead of wrapping or clamping silently. sRGB channels are defined on 0-255; a value outside that range is either a typo or a wide-gamut color that needs gamut mapping, not casual clamping.
Are uppercase and lowercase hex the same color?
#1E90FF and #1e90ff are identical – hex digits are case-insensitive. Lowercase is the common convention in CSS codebases; the tool offers an uppercase toggle output for teams that standardize the other way.
Can I paste percentages like rgb(50% 0% 100%)?
Yes – percentage channels are part of CSS syntax and are scaled by 2.55 to the 0-255 range before conversion. Mixing numbers and percentages in one rgb() is invalid CSS, and the parser tells you so.
Does converting RGB to HEX round anything?
Only if you feed fractional channels: rgb() technically allows 30.6, and hex must land on an integer 0-255, so the channel is rounded to the nearest whole value first. Integer inputs convert exactly.
How is the alpha channel written in hex?
As a fourth pair: rgba(30, 144, 255, 0.6) becomes #1e90ff99, since 0.6Γ255 β 153 = 99 hex. The RGBA to HEX converter on this site does that full 8-digit form.