Home / RGB to HEX converter

RGB to HEX converter

Enter red, green and blue values from 0 to 255 to get the hex code.

RGB values (0–255)

Drag the sliders, type values, or paste an rgb() value.

Advertisement

How to convert RGB to HEX by hand

Convert each of the three values (0–255) into a two-digit base-16 number. Divide the value by 16: the whole-number result is the first digit and the remainder is the second. Numbers 10 to 15 are written as the letters A to F.

ChannelValue÷ 16Hex
Red25515 remainder 15FF
Green875 remainder 757
Blue513 remainder 333

Put them together with a # in front: rgb(255, 87, 51) is #FF5733. Values under 16 get a leading zero, so 10 becomes 0A.

Percentages and transparency

Some tools give RGB as percentages, such as rgb(100%, 34%, 20%). Multiply each by 2.55 and round to get the 0–255 value. You can paste percentage values straight into the converter.

To convert RGBA (RGB with transparency) to hex, convert the alpha too: multiply it by 255 and convert to hex. An alpha of 0.5 is 128, which is 80, so rgba(255, 87, 51, 0.5) is #FF573380.

HEX or RGB in CSS?

Both work everywhere and produce exactly the same color. Hex is shorter and the most common in design tools. RGB is easier to read and adjust, and the modern syntax rgb(255 87 51 / 50%) makes transparency simple.

Advertisement

Frequently asked questions

How do I convert RGB to hex?

Convert each value from 0–255 into two hex digits by dividing by 16 (result, then remainder, with 10–15 written as A–F) and join them after a #. rgb(255, 87, 51) is #FF5733.

How do I convert RGBA to hex?

Convert the red, green and blue values as usual, then multiply the alpha by 255 and convert that too. rgba(255, 87, 51, 0.5) becomes #FF573380.

What if my RGB values are over 255?

Each channel only goes from 0 to 255, so values outside that range are clamped to the nearest limit.

Is there a difference in color between HEX and RGB?

No. They are two ways of writing exactly the same color.

Where do I find a color's RGB values?

Design tools like Photoshop, Figma and Canva show them in the color picker. To get them from an image, use the image color finder.

More free color tools

Advertisement