Home/Calculators/Tech & Data/RGB to Hex Converter

RGB to Hex Converter

Convert red, green and blue channel values into a CSS hex color code.

rgb-to-hex
Result
—
In summary: The values R 255, G 87, B 51 convert to #FF5733. Each channel is written as two hexadecimal digits, so 255 becomes FF, 87 becomes 57 and 51 becomes 33. Values outside 0-255 are clamped to the nearest valid number.

How RGB to hex conversion works

Each channel is a number from 0 to 255, which fits exactly in two hexadecimal digits. Convert to base 16 and pad to two characters: 255 gives FF, 87 gives 57 (87 = 5x16 + 7) and 51 gives 33. Joining them in red-green-blue order with a leading hash produces #FF5733. Values below 0 or above 255 are clamped, and decimals are rounded to the nearest whole number.

Once you are done here, the RGB to HSL converter picks up where this leaves off.

How to use this converter

Enter the three channel values from a design tool, a screenshot picker or a CSS rgb() declaration. The result is shown in uppercase, with the lowercase form in the note beneath - both are valid CSS and the choice is purely a style convention. To read an existing code back into channels, use the hex to RGB converter.

Rounding matters when the source uses percentages or floats: rgb(127.5, 0, 0) rounds to 128 and becomes #800000. Nothing is uploaded — the conversion runs in your browser as you type.

Quick conversion table

Common channel values and their hex pairs:

DecimalHex
000
5133
8757
12880
204CC
255FF

The same base conversion is covered by the decimal to hex calculator.

Worth memorising: #000000 is black, #FFFFFF is white, and any code with three equal pairs such as #808080 is a neutral grey. If red, green and blue are all within a few points of each other the colour will read as grey on screen no matter how it looks in your editor.

Frequently asked questions

What is rgb(255, 87, 51) in hex?
It is #FF5733, formed from FF for red, 57 for green and 33 for blue.
Does uppercase or lowercase hex matter?
No. CSS treats #ff5733 and #FF5733 identically, so pick whichever your codebase already uses.
What happens if I enter a value above 255?
It is clamped to 255, since that is the maximum a single 8-bit channel can hold.
Can I shorten the result to three digits?
Only when each pair repeats, such as #FFCC00 becoming #FC0. #FF5733 cannot be shortened.
Can I convert an rgba() colour with transparency?
Not with a six-digit hex code, which carries only red, green and blue. Convert the three colour channels here, then add the alpha as two extra hex digits (#FF573380 is 50% opacity) if your browser targets support eight-digit hex.
How this tool works

The formula behind this tool is written out in full in the sections above, so you can check the maths yourself. Every calculator on Calculorium is verified against worked examples with automated tests before it is published, and pages are reviewed as formulas or standards change. Nothing you type is sent anywhere — the calculation runs entirely in your browser. Read how we build and check these tools.

Last updated: October 2, 2026 · Calculations run in your browser. Estimates for information only.