EasyUnitConverter.com

RGB to HEX Color Converter

Enter the RGB color values to convert to hex or Hex to RGB.

R255
G87
B51

#FF5733

What does this RGB to Hex converter do?

It takes input in the form of values for Red, Green and Blue ranging from 0 to 255 and then converts those values to a hexadecimal string that can be used to specify color in HTML/CSS code. Photo editing software usually represents color in RGB and therefore if you would like to use the colors you use in your photo editing software as the background of your HTML element then you will have to get the hexadecimal representation of the RGB values. This tool allows you to get those values.

How to Convert RGB to Hex

  1. Get the Red, Green, and Blue color values (each 0-255)
  2. Convert each decimal value to a 2-digit hexadecimal number
  3. Concatenate the 3 hex values with a # prefix

Formula

Hex = "#" + R.toString(16).padStart(2, "0") + G.toString(16).padStart(2, "0") + B.toString(16).padStart(2, "0")

Example

RGB: (255, 87, 51)

Red: 255 = 15×16 + 15 = FF₁₆

Green: 87 = 5×16 + 7 = 57₁₆

Blue: 51 = 3×16 + 3 = 33₁₆

Result: #FF5733

RGB to Hex Color Table

Color NameRGBHexPreview
Black0, 0, 0#000000
White255, 255, 255#FFFFFF
Red255, 0, 0#FF0000
Lime0, 255, 0#00FF00
Blue0, 0, 255#0000FF
Yellow255, 255, 0#FFFF00
Cyan0, 255, 255#00FFFF
Magenta255, 0, 255#FF00FF
Silver192, 192, 192#C0C0C0
Gray128, 128, 128#808080
Maroon128, 0, 0#800000
Olive128, 128, 0#808000
Green0, 128, 0#008000
Purple128, 0, 128#800080
Teal0, 128, 128#008080
Navy0, 0, 128#000080
Orange255, 165, 0#FFA500
Coral255, 127, 80#FF7F50
Tomato255, 99, 71#FF6347
Gold255, 215, 0#FFD700

Technical Details

RGB color model uses 8 bits per channel (0-255), giving 24-bit color depth with 16,777,216 possible colors. Hex color codes represent these same values in base-16 notation, where each channel uses 2 hex digits (00-FF).

Hex colors are used in CSS (color: #FF5733), HTML attributes, SVG, and most web technologies. The shorthand notation uses 3 digits when each pair is identical (e.g., #AABBCC can be written as #ABC).

Frequently Asked Questions

How do I convert RGB to hex?

Convert each RGB value (0-255) to a two-digit hexadecimal number and combine them. For example, RGB(255, 87, 51) becomes FF (255), 57 (87), 33 (51) = #FF5733.

What RGB values make white and black?

White is RGB(255, 255, 255) which converts to #FFFFFF. Black is RGB(0, 0, 0) which converts to #000000. Gray is any value where R, G, and B are equal, like RGB(128, 128, 128) = #808080.

Why do web developers need RGB to hex conversion?

CSS and HTML primarily use hex color codes (#FF5733) rather than RGB notation. When picking colors in design tools that show RGB values, developers need to convert them to hex for use in stylesheets.

What is the range of RGB values?

Each RGB channel ranges from 0 to 255 (8 bits). Zero means no light from that channel, 255 means maximum intensity. This gives 256 x 256 x 256 = 16,777,216 possible colors.

Can I convert RGBA to hex?

Yes. RGBA adds an alpha (transparency) channel. The hex equivalent uses 8 digits (#RRGGBBAA). For example, RGBA(255, 87, 51, 0.5) becomes #FF573380 where 80 is 50% opacity in hex.

Related Converters: