RGBHex

#FF8000
#RGB, #RRGGBB, #RRGGBBAA or rgb()

0–255

0–255

0–255

0–100%

Try

Color codes

The same color in every common format
  • HEX#FF8000
  • Short HEX—
  • RGBrgb(255, 128, 0)
  • HSLhsl(30, 100%, 50%)
  • Decimal16744448
  • Binary11111111 10000000 00000000

Channels in binary

Each channel is one byte, so a color is 24 bits
ChannelDecimalHexBinaryLevel
Red255FF11111111
Green1288010000000
Blue00000000000
Guide

How to convert RGB to hex

  1. Type a hex code like #FF8000 into the hex field, or enter red, green and blue values from 0 to 255. Every other field updates as you type.
  2. To convert RGB to hex by hand, write each channel as two hex digits: 255 is FF, 128 is 80 and 0 is 00, so rgb(255, 128, 0) is #FF8000.
  3. Copy the format you need from the Color codes list: hex, RGB, HSL, a single decimal number or binary.

Worked example

Converting rgb(255, 128, 0) to hex, one channel at a time:

ChannelValue÷ 16Hex
Red25515 r 15FF
Green1288 r 080
Blue00 r 000

rgb(255, 128, 0) → #FF8000

  • Hex color codes aren't case-sensitive: #ff8000 and #FF8000 are the same color.
  • A 3-digit code doubles each digit, so #F80 is #FF8800.
  • Add a fourth byte for transparency: #FF800080 is the same orange at about 50% opacity.
Learn

How hex color codes work

Three bytes per color, shorthand and transparency, and what a color looks like in binary.

An RGB to hex converter turns a color's red, green and blue values into the hex code used in CSS and design tools, and turns hex codes back into RGB. Enter either one above to get the other, along with HSL, transparency and each channel in binary. Here's how hex color codes work, how to convert between RGB and hex by hand, and why there are exactly 16,777,216 of them.

How hex color codes work

Screens mix every color from red, green and blue light. Each of the three channels has a value from 0 (off) to 255 (full brightness), which is exactly one byte. A hex color code writes those three bytes in hexadecimal, two digits each, after a #: #RRGGBB. So #FF8000 means red FF (255), green 80 (128) and blue 00 (0), a bright orange. Two hex digits cover 256 values, from 00 to FF, which is why hex is such a compact way to write a byte.

Converting RGB to hex by hand

Convert each channel to two hex digits and write them in order. Divide the value by 16: the whole-number result is the first digit and the remainder is the second, with 10 to 15 written as A to F. For 255, that's 15 remainder 15, or FF. For 128, it's 8 remainder 0, or 80. For 0, it's 00. Put them together and rgb(255, 128, 0) becomes #FF8000. Values below 16 need a leading zero, so 9 is 09, not 9. The decimal to hex converter shows the division for any number.

Converting hex to RGB

To go from hex to RGB, split the code into three pairs and convert each pair to decimal: multiply the first digit by 16 and add the second. In #1E90FF, 1E is 1 × 16 + 14 = 30, 90 is 9 × 16 + 0 = 144, and FF is 255, so the color is rgb(30, 144, 255). The hex to decimal converter walks through each digit if you'd like to check.

Shorthand and transparency

CSS also accepts 3-digit codes, where each digit is doubled: #F80 means #FF8800 and #FFF means white. It only works when both digits of every pair match. For transparency, add a fourth byte, the alpha channel: #RRGGBBAA. FF is fully opaque and 00 fully transparent, so #FF800080 is the same orange at 128/255, about 50% opacity. In RGB notation, the same color is rgba(255, 128, 0, 0.5). The converter accepts all of these forms, and the Opacity field sets the alpha for you.

Colors in binary

Because each channel is one byte, a hex color is a 24-bit number. #FF8000 in binary is 11111111 10000000 00000000: eight bits each for red, green and blue. Read as a single integer, it's 16,744,448. With 256 levels per channel, 256 × 256 × 256 gives 16,777,216 possible colors, which is where the phrase "24-bit true color" comes from. The Channels in binary table shows each byte of your color.

Common colors in hex and RGB

ColorHexRGB
Black#000000rgb(0, 0, 0)
White#FFFFFFrgb(255, 255, 255)
Red#FF0000rgb(255, 0, 0)
Lime#00FF00rgb(0, 255, 0)
Blue#0000FFrgb(0, 0, 255)
Gray#808080rgb(128, 128, 128)
Orange#FFA500rgb(255, 165, 0)
Dodger blue#1E90FFrgb(30, 144, 255)

Contrast and readable text

When you pick a color for text or a button, check that it stands out from its background. The Web Content Accessibility Guidelines (WCAG) ask for a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text. Contrast depends on how bright each color looks, not on its hex digits: the eye is most sensitive to green, so #00FF00 looks far brighter than #0000FF even though both have one channel at full strength. The preview above switches between dark and light text for the same reason.

RGB, hex and HSL

RGB and hex describe exactly the same thing in two notations. HSL describes the color differently: hue as an angle on the color wheel, then saturation and lightness as percentages. #FF8000 is hsl(30, 100%, 50%), a fully saturated color 30 degrees from red. HSL is handy for making a color lighter or darker by changing a single number, and every modern browser accepts all three forms.

More ways to use it

  • Use Pick a color to choose a color visually, then copy its code.
  • You can paste rgb(255, 99, 71) or rgba(…) straight into the hex field to convert it.
  • For any other hex value, the hex converter shows its decimal, binary and octal forms.

A quick way to read any hex color: the first pair is red, the second green and the third blue. So #FF0000 is pure red, #00FF00 pure green and #808080 a mid gray.

FAQ

Frequently asked questions

Quick answers about the rgb to hex converter and how it works.

How do I convert RGB to hex?

Write each of the red, green and blue values (0 to 255) as two hex digits and put them after a #. 255 is FF, 128 is 80 and 0 is 00, so rgb(255, 128, 0) is #FF8000. Enter the values above and the code appears instantly.

How do I convert hex to RGB?

Split the code into three pairs and convert each to decimal by multiplying the first digit by 16 and adding the second. #1E90FF gives 1E = 30, 90 = 144 and FF = 255, so it's rgb(30, 144, 255). Paste any hex code into the converter to see it.

What does a 3-digit hex color mean?

It's shorthand where each digit is doubled. #F80 is #FF8800, and #FFF is #FFFFFF, white. The converter shows the short form whenever a color has one.

How do I add transparency to a hex color?

Add a fourth pair of digits for the alpha channel: FF is fully opaque and 00 is fully transparent. 80 is 128 out of 255, about 50%, so #FF800080 is half-transparent orange. Set the Opacity field and the converter adds the right pair.

How many colors can a hex code represent?

16,777,216. Each of the three channels has 256 levels, and 256 × 256 × 256 = 16,777,216. That's 24 bits of color, 8 bits per channel.

Are hex color codes case-sensitive?

No. #ff8000, #FF8000 and #Ff8000 are the same color. Use the Uppercase switch to choose how the converter writes them.

Still have a question?Contact us