About the RGB to HEX
Type an rgb() value such as rgb(16, 185, 129) and this tool shows its HEX code right away, together with HSL and CMYK values, a preview swatch, and contrast against white and black.
How it works
Each RGB channel is a number from 0 to 255. To write it in HEX, divide it by 16: the whole-number result is the first hex digit and the remainder is the second, using a-f for 10-15. Red 255 becomes ff, green 87 becomes 57, and blue 51 becomes 33, so rgb(255, 87, 51) is #ff5733.
Type an rgb() value and the tool converts each channel to two hexadecimal digits to build the HEX code, then calculates HSL and CMYK from the same three channels. Because the two formats hold exactly the same information, the RGB values you see always match the HEX code shown.
How to use
- 1
Type an rgb() value into the Color field, for example rgb(16, 185, 129).
- 2
Check the preview swatch.
- 3
Read the HEX row.
- 4
Click the copy icon in the HEX row to copy it.
Worked examples
Orange from RGB values
A designer gives you rgb(255, 87, 51).
255 = ff, 87 = 57, 51 = 33 in base 16.
Tailwind-style blue
Checking that rgb(37, 99, 235) is the expected brand blue.
Black
The simplest case.
Frequently asked questions
What range of values does RGB use?+
Each of the red, green, and blue channels ranges from 0 to 255, which maps to 00 through ff in HEX.
Can I convert RGBA values that include transparency?+
Not with this tool. It works with solid colors only. You can add transparency afterward in CSS using rgb() with an alpha value or an eight-digit HEX code.
How do I type RGB numbers?+
Click the color swatch to open your browser's color picker. In browsers that offer it, switch the picker to RGB mode and type the three values; the HEX code updates to match.
Why is my HEX code six digits?+
Each of the three channels needs two hex digits to represent values from 0 to 255, so a full color takes six.
Is RGB to HEX conversion exact?+
Yes. Both formats store the same three 8-bit values, so there is no rounding or loss of color.