RGB-to-Hex Conversion

JavaScript FAQ | JavaScript Colors FAQ  

Question: How do I convert RGB values of a color to a hexadecimal string?

Answer: The RGB-to-hexadecimal converter algorithm is simple: make sure that your

R
,
G
,
B
(red, green, blue)
values are in the range 0...255, convert
R
,
G
,
B
to hex strings, and then concatenate the three hex strings together. Convert RGB to Hex color values here:
   
  R: G: B:  

Source code Source code | See also Hex-to-RGB | RGB-to-CMYK | RGB-to-HSV | Color names