Convert RGB Color to Hex
Convert RGB values to a hexadecimal code with a color preview.
Your data is never sent to any server.
The RGB to hex converter turns the three channels of a color into the six-digit code used by CSS, HTML and design tools. Type the red, green and blue values and copy the result, with a swatch of the color to check it is the one you expected.
Channel by channel
Each channel is translated on its own into two base 16 digits, and the three are
written one after another behind the #:
| Channel | Decimal | Hex |
|---|---|---|
| Red | 59 | 3B |
| Green | 130 | 82 |
| Blue | 246 | F6 |
Result: #3B82F6. A value below 16 needs a leading zero to fill its two digits:
10 is 0A, not A. Forgetting that zero is the most common mistake when
converting by hand, and it shifts every channel that comes after it.
Why so many people use hex
Both formats describe exactly the same color, but hex is shorter, copies in one go without commas or brackets, and is what Figma, Photoshop and browser color pickers show by default. That is why it tends to be the format of style guides and of a project’s color variables.
How to use RGB to Hex
- 1
Enter the red, green and blue values
Type a number from 0 to 255 in each field. If you go out of range, the value is clamped to the nearest limit.
- 2
Check the color
As soon as the three fields have a value, the hex code appears next to a swatch of the color. Change any channel and both update instantly.
- 3
Copy the code
Press the copy button to take the hex code, with its #, ready to paste into CSS or your design tool.
Frequently asked questions
How do I convert an RGB value to hex by hand?
Divide the value by 16: the quotient is the first digit and the remainder is the second, writing 10 to 15 as A–F. For example, 200 divided by 16 is 12 with 8 left over, so 200 is C8.
Why is the code six digits long?
Two per channel. Each pair goes from 00 (0) to FF (255), which is exactly the range of an RGB channel.
Can I shorten it to three digits?
Only when both digits of every channel match: #FFAA00 can be written #FA0. Otherwise you need the six-digit form to keep the exact color.
What if my color has transparency?
This page works with opaque colors. If you have a fourth opacity value, the RGBA to hex converter gives you the 8-digit code that includes it.