Tool · RGB to HEX

RGB to HEX converter.

Type red, green and blue values (0 to 255, or percentages) and get the six digit HEX code used in CSS, Figma and Tailwind.

Three values 0 to 255, or percentages. rgb( ) wrapper optional.

Nearest named color: Sapphire
HEX out
#1B4DE4
#1B4DE4
Each channel becomes two hexadecimal digits: divide by 16 for the first digit and take the remainder for the second, using A to F for 10 to 15. The conversion is exact in both directions.

What is the rgb to hex?

RGB to HEX converts red, green and blue values (0 to 255 each) into the six-digit hexadecimal code used in CSS and design tools. rgb(27, 77, 228) becomes #1B4DE4.

How RGB to HEX conversion works

Each channel from 0 to 255 is written as two hexadecimal digits: divide by 16 for the first digit and take the remainder for the second, using A to F for 10 to 15. 228 is 14 times 16 plus 4, so E4. Join the three pairs after a hash. The converter accepts rgb(), comma-separated numbers or percentages, and rgba() with alpha, which becomes an eight-digit HEX.

Where HEX is used

HEX is the default in CSS, HTML, Figma, Sketch, Tailwind config and most brand guidelines. RGB is what image software, video and code that manipulates pixels use. Both describe the same sRGB color, so the conversion is exact.

RGB to HEX FAQ

How do I convert RGB to HEX?

Enter the three values here or in any format the field accepts. Each value is converted to two hex digits and joined with a hash.

What is rgb(0, 0, 0) in HEX?

#000000, black. rgb(255, 255, 255) is #FFFFFF, white.

Can I convert RGB percentages?

Yes. rgb(50%, 20%, 90%) is accepted and converted to #8033E6.

Related color tools

Learn more