RGB to HEX Converter

Convert red, green and blue channels into a six-digit HEX color. Enter integers from 0 to 255 or paste a complete value such as rgb(255, 87, 51).

Conversion happens locally in your browser; no color data is uploaded.

0–255
0–255
0–255

HEX result
#FF5733
rgb(255, 87, 51)

What RGB and HEX mean

RGB describes screen colors with three decimal channels: red, green and blue. Each channel ranges from 0 (none of that light) to 255 (full intensity). HEX represents the same channels with hexadecimal pairs from 00 to FF. A six-digit code follows #RRGGBB.

How to convert RGB to HEX

  1. Check that each RGB channel is a whole number from 0 to 255.
  2. Convert each decimal channel to base 16.
  3. Add a leading zero when a result has one digit.
  4. Join the red, green and blue pairs after #.

Formula: # + hex(R) + hex(G) + hex(B). For rgb(255, 87, 51), 255 becomes FF, 87 becomes 57, and 51 becomes 33, giving #FF5733.

Using the result in CSS

HEX and RGB are interchangeable for solid sRGB colors. For example, color: #FF5733; and color: rgb(255, 87, 51); display the same color. HEX is compact for design tokens; RGB can be convenient when channel values are already available in code.

Common RGB to HEX colors

ColorRGBHEX
Blackrgb(0, 0, 0)#000000
Whitergb(255, 255, 255)#FFFFFF
Redrgb(255, 0, 0)#FF0000
Greenrgb(0, 128, 0)#008000
Bluergb(0, 0, 255)#0000FF
Orangergb(255, 165, 0)#FFA500
Rebecca purplergb(102, 51, 153)#663399

RGB to HEX questions

Are lowercase and uppercase HEX codes different?

No. #ff5733 and #FF5733 represent the same color; this tool uses uppercase for consistent output.

Can RGB channels contain decimals?

Standard 8-bit RGB channels are integers from 0 to 255. This converter asks you to correct decimals instead of silently rounding them.

What happens to invalid values?

Empty, negative, decimal, or above-255 channels show an error and do not replace the last valid result.

Related color tools