RGB to hex converter
Turn any RGB value into its hex color code, with the matching HSL, OKLCH, CMYK and Tailwind values ready to use in your CSS.
rgb(), rgba() or plain numbers like 226 100 154.
Hex
White text3.22:1Fails AA
Black text6.52:1Passes AA
Other formats
Copy every format and code snippet in one click.
Free and open source
Turn one color code intopages, ads and prototypes.
Agent-Native Design builds each one around your color, with readable text on every background.
RGB to hex in JavaScript and Python
Common colors in RGB and hex
| Color | RGB | Hex |
|---|---|---|
| White | 255, 255, 255 | #FFFFFF |
| Black | 0, 0, 0 | #000000 |
| Red | 255, 0, 0 | #FF0000 |
| Green | 0, 255, 0 | #00FF00 |
| Blue | 0, 0, 255 | #0000FF |
| Yellow | 255, 255, 0 | #FFFF00 |
| Cyan | 0, 255, 255 | #00FFFF |
| Magenta | 255, 0, 255 | #FF00FF |
| Gray | 128, 128, 128 | #808080 |
| Orange | 255, 165, 0 | #FFA500 |
More free color tools
FAQs
RGB to hex questions
Type the red, green and blue values into the converter and copy the hex code. To convert by hand, write each value from 0 to 255 as two base-16 digits. Then join the three pairs after a #.
Divide each channel by 16. The whole number is the first hex digit and the remainder is the second. Digits 10 to 15 are written A to F. Join red, green and blue in that order as #RRGGBB.
Set alpha below 100% and the converter adds a fourth pair. At 50%, #E2649A becomes #E2649A80. All current browsers support 8-digit hex in CSS.
FF is 255 in base 16. That's the highest value a channel can have. #FF0000 is full red with no green or blue.
Yes. RBG is a common typo for RGB. RGB stands for red, green and blue, always in that order. Hex codes use the same order.
A 6-digit hex code can show 16,777,216 colors. Each of the three channels has 256 values.
Hex codes describe sRGB colors. An app that uses Display P3 or a print profile can show the same code a little differently.