← Zaps Colors
Converter

HEX to RGB Converter

Paste a HEX code to get RGB, or type RGB values to get HEX. Both sides update as you type.

3, 6 or 8 digits, with or without #

Or RGB values
HEX#FF922E
RGBrgb(255, 146, 46)
RGBArgba(255, 146, 46, 1)
HSLhsl(29, 100%, 59%)

What this converter does

It converts color codes in both directions. Paste a HEX code to get its rgb(), rgba() and hsl() values, or type red, green and blue numbers to get the HEX code. It reads 3, 6 and 8 digit HEX codes, with or without the #, and updates as you type.

How to convert HEX to RGB

  1. Paste a HEX code such as #ff922e or ff922e into the HEX field.
  2. Read the result in the RGB, RGBA and HSL rows.
  3. Click Copy on the row you need.

To convert RGB to HEX, type values from 0 to 255 into R, G and B, then copy the HEX row. Set Alpha below 1 to get an 8-digit HEX code with transparency.

How HEX maps to RGB

A six-digit HEX code is three pairs of base 16 digits: red, green, then blue. Each digit runs from 0 to 9 and then A to F, which stand for 10 to 15. To turn a pair into a number from 0 to 255, multiply the first digit by 16 and add the second.

FF  =  15 × 16 + 15  =  255   red
92  =   9 × 16 +  2  =  146   green
2E  =   2 × 16 + 14  =   46   blue

#FF922E  =  rgb(255, 146, 46)

RGB to HEX runs the same math backward. Divide each value by 16: the whole number is the first digit and the remainder is the second, so 146 ÷ 16 is 9 remainder 2, which gives 92.

Common colors in HEX and RGB

ColorHEXRGB
Red#FF0000rgb(255, 0, 0)
Orange#FFA500rgb(255, 165, 0)
Yellow#FFFF00rgb(255, 255, 0)
Green#008000rgb(0, 128, 0)
Teal#008080rgb(0, 128, 128)
Blue#0000FFrgb(0, 0, 255)
Navy blue#000080rgb(0, 0, 128)
Purple#800080rgb(128, 0, 128)
Pink#FFC0CBrgb(255, 192, 203)
White#FFFFFFrgb(255, 255, 255)
Gray#808080rgb(128, 128, 128)
Black#000000rgb(0, 0, 0)

Need a color first? Find one with the color picker. Then check text on it with the contrast checker, get lighter and darker versions from the tint and shade generator, or blend two codes in the color mixer. The color wheel and palette generator build a full set around one color.

HEX to RGB FAQ

How do I convert HEX to RGB?

Split the six digits into three pairs for red, green and blue. Convert each pair from base 16 by multiplying the first digit by 16 and adding the second, where A to F stand for 10 to 15. #FF922E becomes 255, 146 and 46, written as rgb(255, 146, 46).

How do I convert RGB to HEX?

Divide each of the three values by 16. The whole number is the first HEX digit and the remainder is the second, with 10 to 15 written as A to F. Join the three pairs after a #. For example, rgb(59, 130, 246) gives 3B, 82 and F6, so the code is #3B82F6.

What does an 8-digit HEX code mean?

The last two digits set the opacity, also called alpha. 00 is fully transparent and FF is fully opaque, so #FF922E80 is the same orange at about 50% opacity. To get the alpha for rgba(), divide the pair's decimal value by 255. 80 is 128, and 128 ÷ 255 rounds to 0.5.

Is a 3-digit HEX code the same as a 6-digit one?

Yes, it is shorthand. Browsers double each digit, so #F80 means #FF8800 and #FFF means #FFFFFF. Only colors whose pairs repeat a digit have a short form, which limits three-digit codes to 4,096 colors, while six digits can express about 16.7 million.

Should I use HEX or RGB in CSS?

Either one works, and browsers render them identically. HEX is shorter and easy to paste from design tools. rgb() is easier to read and to tweak one channel at a time. For transparency, use an 8-digit HEX code or rgb() with an alpha value. Current browsers support both.