hex2dec.com

RGB to Hex Color Converter

Convert RGB values to hex color codes instantly. Adjust the sliders or enter values directly for live hex, HSL, and CSS output.

RGB to Hex Converter

Adjust RGB values to get the hex color code

HEX#FF5733
RGBrgb(255, 87, 51)
HSLhsl(11, 100%, 60%)

How to Convert RGB to Hex

  1. 1Take your RGB values, e.g., R=255, G=87, B=51.
  2. 2Convert each value to hexadecimal: divide by 16. For 255: 255 ÷ 16 = 15 remainder 15 → FF. For 87: 87 ÷ 16 = 5 remainder 7 → 57. For 51: 51 ÷ 16 = 3 remainder 3 → 33.
  3. 3Concatenate the three hex pairs: FF + 57 + 33 = FF5733.
  4. 4Add the # prefix: #FF5733

Common RGB to Hex Conversions

ColorRGBHexPreview
Redrgb(255, 0, 0)#FF0000
Greenrgb(0, 255, 0)#00FF00
Bluergb(0, 0, 255)#0000FF
Whitergb(255, 255, 255)#FFFFFF
Blackrgb(0, 0, 0)#000000
Yellowrgb(255, 255, 0)#FFFF00
Cyanrgb(0, 255, 255)#00FFFF
Magentargb(255, 0, 255)#FF00FF
Orangergb(255, 165, 0)#FFA500
Purplergb(128, 0, 128)#800080
Pinkrgb(255, 192, 203)#FFC0CB
Tealrgb(0, 128, 128)#008080

Frequently Asked Questions

What is RGB?

RGB stands for Red, Green, Blue. It's a color model where each channel ranges from 0 to 255, representing the intensity of that color. Combining the three channels produces any color in the sRGB color space.

How do I convert RGB to hex?

Take each RGB value (0-255) and convert it to a 2-digit hexadecimal number. For example, RGB(255, 87, 51): 255 → FF, 87 → 57, 51 → 33. Combine them with a # prefix: #FF5733.

Why do hex color codes use letters?

Hexadecimal is a base-16 number system. After 0-9, it uses A (10) through F (15). So the value 255 becomes FF in hex. This keeps each channel to exactly 2 characters, making hex codes compact.

What is the difference between RGB and hex?

They represent the same colors. RGB uses three decimal numbers (0-255), while hex encodes the same values as a 6-character hexadecimal string prefixed with #. Both are valid in CSS.

Can I use RGB and hex interchangeably in CSS?

Yes. Both `color: #FF5733;` and `color: rgb(255, 87, 51);` are valid CSS. Hex is more compact and commonly used in design tools, while RGB (and RGBA) is needed when you want to specify opacity.

How do I convert RGB to hex manually?

Divide each RGB value by 16 to get the first hex digit (remainder gives the second). For example, R=200: 200 ÷ 16 = 12 (C) remainder 8 → C8. Repeat for G and B, then concatenate: #C8.... Alternatively, use our converter above for instant results.