RGB to HEX Converter
Convert rgb colors to hex format instantly.
Convert rgb colors to hex format instantly.
Converting RGB to HEX is a simple base-10 to base-16 conversion applied to each channel. Each decimal value (0โ255) becomes a two-digit hexadecimal pair, and the three pairs are concatenated with a # prefix.
#FF5733 from rgb(255, 87, 51)bgcolor="#FF5733")Use .toString(16).padStart(2, '0') on each channel: const toHex = (r, g, b) => '#' + [r, g, b].map(v => v.toString(16).padStart(2, '0')).join(''); For example, toHex(255, 87, 51) returns #ff5733. Use .toUpperCase() if you prefer uppercase hex.
Black = #000000 (R:0, G:0, B:0 โ no light). White = #FFFFFF (R:255, G:255, B:255 โ full light on all channels). Middle gray = #808080 (128, 128, 128). Pure red = #FF0000, pure green = #00FF00, pure blue = #0000FF.
Yes โ color: rgb(255, 87, 51) is valid CSS. Modern CSS also supports the space-separated syntax without commas: rgb(255 87 51) and fractional percentages: rgb(100% 34% 20%). The HEX equivalent is purely a formatting preference โ both produce identical colors.