RGB to HEX Converter

Convert rgb() or rgba() values to a hex color code. Accepts CSS notation and bare numbers like 59, 130, 246, and returns hex with or without alpha.

RGB color

Hexadecimal values

Enter a color value to see the result.

RGB to HEX Converter

How RGB and hex colors relate

An RGB colour lists the red, green and blue channels as decimal numbers from 0 to 255. A hex colour stores the same three channels as two hexadecimal digits each, so rgb(59, 130, 246) and #3B82F6 describe exactly the same blue.

When a colour has transparency, CSS writes it as rgba() with a fourth value between 0 and 1, while hex appends a fourth pair for the alpha channel. The converter shows both, so you can pick the form your code needs.

How to convert RGB to hex

  1. Paste an rgb() or rgba() value, or type the three numbers separated by commas.
  2. Press Convert to HEX.
  3. Check the preview swatch and the HEX or HEX8 output.
  4. Copy the hex code you need, or use the RGB and RGBA rows to confirm the values were read correctly.

RGB to hex examples

Standard rgb() value

rgb(59, 130, 246)
#3B82F6

rgba() with transparency

rgba(59, 130, 246, 0.5)
#3B82F680

Plain comma separated numbers

255, 255, 255
#FFFFFF

UrsaKit vs other RGB to hex converters

DimensionUrsaKitrgbtohex.netHTML Color Codes
PriceFreeFreeFree with ads
Bare number inputYesPartialNo
Alpha handlingYes, rgba() to hex8PartialYes
Copy individual valuesYesNoPartial
Preview swatchYesYesYes
Uploads your colorNoNoNo
FAQ

Frequently asked questions

Can I type just the numbers without rgb()?

Yes. 59, 130, 246 is parsed the same way as rgb(59, 130, 246), and numbers can be separated by commas or spaces.

How is alpha converted?

The 0 to 1 alpha value is multiplied by 255 and written as the fourth hex pair, so rgba(59, 130, 246, 0.5) becomes #3B82F680.

What is the difference between HEX and HEX8?

HEX is the six digit code for the colour. HEX8 adds two digits for the alpha channel and is only needed when the colour is partly transparent.

What numbers are valid?

Each channel must be a whole number from 0 to 255, and alpha must be between 0 and 1 or a percentage from 0% to 100%.

Is my input uploaded?

No. The conversion runs in your browser with JavaScript and nothing is sent to a server.

Can I go back from hex to RGB?

Yes. Use the hex to RGB converter linked below to turn a hex code into rgb() or rgba() values.

All Tools