Hex to RGB converter

Type or paste a hex code such as #2E8B57 to convert it to RGB: rgb(46, 139, 87). The converter reads 3, 6 and 8-digit hex colors, with or without the #, and shows the working for each pair.

RGB to hex
0 to 1

Show the working
Click any value to copy it.
Checked byTomeshia Brock
Reviewed byJacob Seto
Last updated · How we test

Runs in your browser. Nothing you type is uploaded.

How to use the hex to RGB converter

  1. Type or paste a hex code into the Hex box. The # is optional, and uppercase or lowercase both work.
  2. Read the RGB answer under the swatch. Click any value to copy it, or press Copy RGB.
  3. Paste a whole CSS value such as #2e8b57 or 0x2E8B57 into Paste if you copied it from code.
  4. Drag the sliders or use the color picker to adjust the color, and the hex and RGB values update together.

Under the result you also get HSL, HSV, CMYK, the color as one decimal number and in binary, plus its contrast against white and black text. To go the other way, use the RGB to hex tab above the tool.

How to convert hex to RGB

Hex to RGB example: 2E is 2 times 16 plus 14, which is 46. 8B is 8 times 16 plus 11, which is 139. 57 is 5 times 16 plus 7, which is 87. So #2E8B57 is rgb(46, 139, 87).

A 6-digit hex color code is three pairs: red, green and blue. Each pair is a number from 00 to FF, which is 0 to 255 in decimal, and the hexadecimal table lists every one. To turn one pair into a number, multiply the first digit by 16 and add the second, which the hex to decimal converter shows step by step. The digits A to F stand for 10 to 15.

ChannelHex pairFirst × 16 + secondValue
Red2E2 × 16 + 1446
Green8B8 × 16 + 11139
Blue575 × 16 + 787

So #2E8B57 is rgb(46, 139, 87), the color called sea green in CSS, listed as seagreen in MDN's CSS named color table. Open "Show the working" under the tool to see the same table for any code you type.

Hex code to RGB for short and long codes

CodeLengthMeansRGB
#F803 digitsEach digit doubled: #FF8800rgb(255, 136, 0)
#2E8B576 digitsRed, green, bluergb(46, 139, 87)
#2E8B57808 digitsRed, green, blue, alphargba(46, 139, 87, 0.5)
#F8084 digitsShort form with alpha: #FF880088rgba(255, 136, 0, 0.53)

The alpha pair sets transparency. FF is fully opaque, 80 is about half and 00 is fully transparent. The tool shows an RGBA value whenever the alpha is below 1.

Hex code lengths: #F80 is the short form of #FF8800, which is rgb(255, 136, 0). #2E8B57 is rgb(46, 139, 87). #2E8B5780 adds an alpha of 80, about half, giving rgba(46, 139, 87, 0.5).

Hex color to RGB chart

HexRGBColor
#0000000, 0, 0Black
#FFFFFF255, 255, 255White
#FF0000255, 0, 0Red
#00FF000, 255, 0Lime green
#0000FF0, 0, 255Blue
#FFFF00255, 255, 0Yellow
#808080128, 128, 128Gray
#FFA500255, 165, 0Orange
#800080128, 0, 128Purple
#FFC0CB255, 192, 203Pink

Hex to RGB, HSL and CMYK

The same hex color can be written several ways, and the tool shows them all at once. For #2E8B57 that is RGB 46, 139, 87, HSL 146°, 50%, 36%, and CMYK 67%, 0%, 37%, 45%. HSL is handy for making a lighter or darker shade. The CMYK numbers are a simple formula for screen colors, so check them against a printer profile before you print.

Where you need RGB instead of hex

  • CSS functions such as rgba() when you want to add transparency to a brand color.
  • Design and video tools that ask for separate red, green and blue fields.
  • Code for LEDs, games and charts, where colors are often set as three numbers from 0 to 255.
  • Color math, such as mixing two colors or making a lighter shade, which is easier on numbers than on hex text.

Both notations describe exactly the same color, so converting back and forth never changes it.

Frequently asked questions

How do I convert a hex code to RGB?

Split the code into three pairs. For each pair, multiply the first digit by 16 and add the second, using 10 to 15 for A to F. The three results are the red, green and blue values.

What is #FFFFFF in RGB?

rgb(255, 255, 255), which is white. #000000 is rgb(0, 0, 0), black.

Does the # matter?

No. The tool reads the code with or without it, and also accepts a 0x prefix.

Can I convert an 8-digit hex code?

Yes. The last two digits are the alpha, and the tool shows the result as an rgba() value.

Is hexadecimal to RGB conversion exact?

Yes. Hex and RGB are two ways of writing the same 0 to 255 values, so nothing is rounded and you can convert back with RGB to hex.

Scroll to Top