Convert color from RGB to HEX

RGB to HEX converter

Turn RGB values into a HEX color code.

Example: rgb(255, 107, 53)

HEX
See this color in all formats

About RGB to HEX Converter

CSS, SVG and most design handoff tools take HEX codes: they are shorter than rgb(), easy to paste and what brand guidelines usually list. Each of the red, green and blue numbers becomes two hex digits (0 to 255 turns into 00 to ff), so the conversion is exact.

About the formats. RGB gives the amount of red, green and blue light as three numbers from 0 to 255, as in rgb(255, 107, 53). Both the comma form and the space form rgb(255 107 53 / 50%) are read, and percentages work too. A HEX code writes the red, green and blue channels as two hexadecimal digits each, so #ff6b35 is red ff (255), green 6b (107) and blue 35 (53). The leading # is optional here, the short forms #f63 and #f63a work, and the 8-digit form #RRGGBBAA adds transparency.

How exact is it? RGB channels are read as they are and rounded to the nearest whole number when they carry decimals, so a normal rgb() value is never altered. The result is written as six hex digits (eight when the color is partly transparent), which gives one of 256 levels per channel.

For example, rgb(29, 53, 87) in RGB is #1d3557 in HEX. The input can be rgb(29, 53, 87), the space form rgb(29 53 87) or just 29, 53, 87. Percentages work too, so rgb(100% 0% 0%) is #ff0000. If you add transparency, as in rgba(29, 53, 87, 0.5), the result is an 8-digit HEX code.

How to convert RGB to HEX

  1. Type or paste an RGB color, such as rgb(29, 53, 87), or choose a color with the picker.
  2. The HEX value, #1d3557 for that example, appears straight away.
  3. Press Copy to put the HEX value on your clipboard.
  4. Use the From and To menus at the top to switch to a different conversion, or open the all-formats page to see every format at once.

Frequently asked questions

How do I convert RGB to HEX?

Type or paste an RGB value such as rgb(29, 53, 87) and the HEX value, #1d3557, appears straight away. Use Copy to put it on your clipboard, or choose a color with the picker.

Why does my RGB value have decimals?

Some tools export fractional values like 254.6. HEX cannot hold fractions, so each channel is rounded to the nearest whole number before it is written.

Can I get a 3-digit HEX code?

Only when each pair of digits repeats, like #ff6633, which can be shortened to #f63. This converter always gives the full six digits (or eight with transparency), which every tool accepts.

Is converting RGB to HEX exact?

RGB channels are read as they are and rounded to the nearest whole number when they carry decimals, so a normal rgb() value is never altered. The result is written as six hex digits (eight when the color is partly transparent), which gives one of 256 levels per channel.

Does RGB to HEX keep transparency?

Yes. Add transparency to the RGB value and it is carried over to the HEX result, which supports it too.

Are my colors sent anywhere?

No. The conversion runs in your browser and nothing is uploaded.