What is an RGB to HEX converter?
An RGB to HEX converter rewrites red, green, and blue channel values as hexadecimal pairs. RGB normally uses decimal channels from 0 to 255; HEX represents the same sRGB channels from 00 to FF.
How to convert RGB to HEX
- Enter three RGB channels as
rgb(255, 87, 51),255 87 51, or percentages. - Check the color preview and each decimal-to-HEX channel pair.
- Copy the HEX format required by your stylesheet or design tool.
The converter updates immediately. It accepts comma- or space-separated values, but not normalized 0–1 input or alpha channels.
RGB to HEX formula and example
Convert each decimal channel to a two-digit hexadecimal value:
255 = FF87 = 5751 = 33Joining the pairs produces #FF5733. Values below 16 receive a leading zero, so decimal 10 becomes 0A.
RGB percentages
Percentage channels are converted to the nearest 0–255 integer before the HEX code is created. For example, rgb(100% 34.1% 20%) becomes #FF5733 after channel rounding.
RGB vs. HEX
RGB exposes decimal channels and is useful in CSS functions, Canvas APIs, and graphics code. HEX is compact and common in stylesheets and design tokens. Neither format adds transparency unless an alpha channel is included.
Need the reverse direction? Use the HEX to RGB Converter. To edit the same color as hue, saturation, and lightness, use the RGB to HSL Converter.
RGB to HEX FAQ
Can RGB values contain percentages?
Yes. Each percentage must be between 0% and 100%.
Why are some HEX pairs padded with zero?
Every RGB channel needs exactly two HEX digits. Decimal values from 0 to 15 therefore use pairs from 00 to 0F.
When is three-digit HEX available?
Only when both digits in every pair match. For example, #AABBCC can be shortened to #ABC, but #A1B2C3 cannot.
Does letter case change a HEX color?
No. #FF5733 and #ff5733 represent the same color.
Why is rgba() rejected?
RGBA includes transparency, which six-digit HEX cannot preserve. This converter does not silently discard it.