World’s largest virtual agentic engineering & quality conference

WHENAUG 19-21
WHEREVirtual · Global
WATCH NOW

RGB to HEX Converter Online

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.

Categories

...

3000+ Browsers. One Platform.

See exactly how your site performs everywhere.

Try it free
...

Write Tests in Plain English with KaneAI

Create, debug, and evolve tests using natural language.

Try for free
...
TestMu Conf 2026

World's largest virtual agentic engineering & quality conference

...

AUG 19-21, 2026

WATCH NOW

Red

Green

Blue

Hex

What are HEX and RGB color values?

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.

How does RGB to HEX work?

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.

How to convert RGB to hex?

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.

Are hex codes always 6 digits?

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.

Why is RGB 255 and not 256?

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.

Common RGB to HEX Conversion Table

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.

ColorRGB ValueHEX Code
Blackrgb(0, 0, 0)#000000
Whitergb(255, 255, 255)#FFFFFF
Redrgb(255, 0, 0)#FF0000
Greenrgb(0, 255, 0)#00FF00
Bluergb(0, 0, 255)#0000FF
Yellowrgb(255, 255, 0)#FFFF00
Cyanrgb(0, 255, 255)#00FFFF
Magentargb(255, 0, 255)#FF00FF

The Math: How to Manually Convert RGB to HEX

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:

DivisionQuotientRemainderHex Digits
255 ÷ 161515F 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).

Understanding 3-Digit and 8-Digit Hex Codes

A hex color code is not always six digits. Depending on the format, it can be 3, 6, or 8 characters long:

  • 6-digit hex: The standard form, written as #RRGGBB. Each pair of characters sets the Red, Green, and Blue channels, for example #FF0000 for pure red.
  • 3-digit shorthand hex: When each channel uses a repeated pair, the code can be shortened. #F00 expands to #FF0000, and #0AF expands to #00AAFF. Shorthand only works when both characters in every pair are the same.
  • 8-digit hex (RGBA): Written as #RRGGBBAA, this adds a fourth value, the alpha channel, which controls transparency. FF is fully opaque and 00 is fully transparent, so #FF000080 is red at about 50% opacity.

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.

Frequently Asked Questions (FAQs)

What is the color of RGB 255 0 0 in 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).

What is the RGB for hex #000000?

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.

What color is 255 255 255 255?

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.

What is the difference between RGB and RGBA?

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).

Do hex codes use letters or only numbers?

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

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests