World’s largest virtual agentic engineering & quality conference
Use this free online tool to convert RGB color values to HEX color values, which can be used to specify colors in HTML and CSS. Enter your red, green, and blue values into this tool to get the corresponding hexadecimal code. The tool is developed by TestMu AI (formerly LambdaTest) and is completely free to use.
RGB and HEX are two ways of describing the same color, a red, green, and blue value. RGB writes the color as three numbers from 0 to 255, while HEX writes it as a code built from the digits 0-9 and the letters A-F (base 16). HEX values are commonly used in coding, for instance in HTML and CSS files.
There are 3 different input values for Red, Green and Blue which range from 0 to 255. These are then used to convert those values into a hexadecimal string which can be used to specify colors in HTML/CSS code.
Convert each channel value to a two-digit hexadecimal number by dividing it by 16: the quotient is the first hex digit and the remainder is the second (using A-F for 10-15). Concatenate the three two-digit results to form the six-digit hex code.
No. While the full form uses six digits, hex color codes also come in a 3-digit shorthand (for example, #F00 is the same as #FF0000) and an 8-digit form that adds a two-digit alpha channel for transparency (RGBA). So a hex color can be 3, 6, or 8 characters long depending on the format.
In digital systems, data is measured in bits, each holding a 0 or 1. Eight bits grouped together can represent any number from 0 to 255. Because counting starts at 0 rather than 1, the highest value in that 256-step range is 255, so each color channel runs from 0 to 255.
Use this quick reference table to look up the HEX code for common colors. Each RGB value (Red, Green, Blue) maps to a 6-digit hexadecimal code you can paste straight into your HTML or CSS. Most design tools and color pickers display these HEX codes alongside their RGB values.
| Color | RGB Value | HEX Code |
|---|---|---|
| Black | rgb(0, 0, 0) | #000000 |
| White | rgb(255, 255, 255) | #FFFFFF |
| Red | rgb(255, 0, 0) | #FF0000 |
| Green | rgb(0, 255, 0) | #00FF00 |
| Blue | rgb(0, 0, 255) | #0000FF |
| Yellow | rgb(255, 255, 0) | #FFFF00 |
| Cyan | rgb(0, 255, 255) | #00FFFF |
| Magenta | rgb(255, 0, 255) | #FF00FF |
Each RGB channel is a decimal (base 10) number from 0 to 255, and each one becomes a two-character hexadecimal (base 16) value. To convert a single channel by hand, divide the value by 16. The quotient becomes the first hex digit and the remainder becomes the second, using the mapping 10=A, 11=B, 12=C, 13=D, 14=E, and 15=F.
Here is how the red channel value 255 converts to FF:
| Division | Quotient | Remainder | Hex Digits |
|---|---|---|---|
| 255 ÷ 16 | 15 | 15 | F and F |
Do this for all three channels and join the results. For example, rgb(255, 165, 0) becomes FF, A5, and 00 (since 165 ÷ 16 = 10 remainder 5, and 10=A, 5=5), giving the HEX code #FFA500 (orange).
A hex color code is not always six digits. Depending on the format, it can be 3, 6, or 8 characters long:
This is why a value like 255 255 255 255 has four numbers instead of three, it is an RGBA color. The first three values are white (255, 255, 255) and the last value, 255, is the alpha channel set to fully opaque, which is written as #FFFFFFFF in 8-digit hex.
RGB 255, 0, 0 converts to the HEX code #FF0000, which is pure red. The red channel is at its maximum (255 = FF) while green and blue are both 0 (00).
The hex code #000000 is equal to rgb(0, 0, 0), which is black. Every channel is set to 0, meaning no red, green, or blue light is added.
A value with four numbers is an RGBA color, where the fourth number is the alpha (transparency) channel. 255, 255, 255, 255 is white at full opacity, written as #FFFFFFFF in 8-digit hex.
RGB defines a color using red, green, and blue values. RGBA adds a fourth value, the alpha channel, which sets how transparent the color is, from 0 (fully transparent) to 255 (fully opaque).
Hex codes use both. Because they are written in base 16, each digit can be 0-9 or the letters A-F, where A=10 and F=15. That is how values above 9, such as FF for 255, are represented.
Did you find this page helpful?
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance