RGB to HEX Converter

Convert between RGB and HEX color values in both directions, with a live preview. Out-of-range values are clamped rather than silently producing a broken color.

RGB → HEX

Three numbers from 0 to 255, separated by commas or spaces.

HEX color
Enter an RGB value to see the HEX code.

HEX → RGB

3 or 6 digits, with or without the leading #.

RGB color
Enter a HEX value to see the RGB triplet.

How RGB to HEX conversion works

HEX is simply base-16 notation for the same three channels. Each channel (0–255) becomes a two-digit hexadecimal pair:

#RRGGBB  where each pair = value.toString(16).padStart(2, '0')

Worked example. Convert rgb(11, 107, 203):

Result: #0B6BCB

Common colors

NameHEXRGB
Black#000000000
White#FFFFFF255255255
Red#FF000025500
Lime#00FF0002550
Blue#0000FF00255
Cyan#00FFFF0255255
Magenta#FF00FF2550255
Yellow#FFFF002552550
Gray#808080128128128
Crimson#DC143C2202060
Teal#0080800128128
Navy#00008000128

Frequently asked questions

How do I convert RGB to HEX by hand?
Convert each of the red, green and blue values (0–255) to a two digit base-16 number, then join them with a leading hash. For example rgb(11, 107, 203) becomes #0B6BCB.
What happens if I enter a value above 255?
Values are clamped to the valid 0–255 range, so 300 is treated as 255. The converter shows a note whenever clamping occurs so you always know the real output.
Does this tool support 3-digit HEX codes?
Yes. Shorthand codes such as #0af are expanded to #00AAFF, and you can enter them with or without the leading hash.
Is my data uploaded anywhere?
No. The conversion runs entirely in your browser; no color value is ever sent to a server.

Related tools

Last updated: August 31, 2026