Skip to the content

RGB to HEX Converter

Enter red, green and blue values from 0 to 255 and get the six-digit HEX code of the same color.

The numbers alone will do: 255, 99, 71.

In HEX

#ff6347

Hue
9°Alpha
100%

In the other notations

Name

tomatoexact match

Share this tool:TwitterFacebookLinkedInWhatsAppEmail

RGB to HEX by hand

The converter opens with rgb(255, 99, 71). This is how that color gets from RGB to HEX, step by step.

  1. Divide each value by 16. The whole part becomes the first digit and the remainder the second: 255 = 15 × 16 + 15, 99 = 6 × 16 + 3 and 71 = 4 × 16 + 7.
  2. Write the digits in base 16, with a to f for 10 to 15: 15 and 15 make ff, 6 and 3 make 63 and 4 and 7 make 47.
  3. Put the three pairs after a hash sign: #ff6347.

Well-known colors in RGB and HEX

ColorRGBHEX
blackrgb(0, 0, 0)#000000
whitergb(255, 255, 255)#ffffff
grayrgb(128, 128, 128)#808080
redrgb(255, 0, 0)#ff0000
orangergb(255, 165, 0)#ffa500
yellowrgb(255, 255, 0)#ffff00
limergb(0, 255, 0)#00ff00
greenrgb(0, 128, 0)#008000
cyanrgb(0, 255, 255)#00ffff
bluergb(0, 0, 255)#0000ff
purplergb(128, 0, 128)#800080
magentargb(255, 0, 255)#ff00ff

Two digits for every value

  • A value below 16 still takes two digits: 9 is written 09. Without the zero the code is a digit short, and a browser ignores a code of five digits.
  • Percentages are scaled to 255 first. rgb(100%, 50%, 0%) is 255, 127.5 and 0, and 127.5 is rounded up to 128, which is 80.
  • When both digits are the same in all three pairs, the code has a short form: #ffcc00 can be written #fc0.
  • An opacity becomes a fourth pair in the same way: 0.5 × 255 = 127.5, rounded to 128, so rgba(255, 99, 71, 0.5) is #ff634780.

The color converter shows a color in all seven notations at once, with a picker to choose it by eye.

See all 8