HEX to RGB color converter

A HEX color is three pairs of base-16 digits for red, green and blue, so #1E90FF is rgb(30, 144, 255). Type a HEX code or an rgb() value to get every CSS form of the same color, including its alpha if the code has one.

3, 4, 6 or 8-digit HEX with or without #, or an rgb(), rgba(), hsl() or hsla() value with commas or spaces.

RGB

rgb(30, 144, 255)

#1E90FF · hsl(210, 100%, 56%)

#1E90FF
HEX
#1E90FF
rgb()
rgb(30, 144, 255)
rgba()
rgba(30, 144, 255, 1)
hsl()
hsl(210, 100%, 56%)Rounded to whole degrees and percents
CSS Color 4 syntax
rgb(30 144 255)Space-separated, alpha after a slash
The color channel by channel
ChannelHEXValuePercent of full
Red1E3011.8%
Green9014456.5%
BlueFF255100%

How do you convert HEX to RGB?

A six-digit HEX code is three pairs of base-16 digits for red, green and blue. Each pair runs from 00 to FF, which is 0 to 255: the first digit times 16 plus the second. In #1E90FF, 1E = 1 × 16 + 14 = 30, 90 = 9 × 16 + 0 = 144 and FF = 15 × 16 + 15 = 255, so the color is rgb(30, 144, 255). The letters can be upper or lower case.

Three- and four-digit codes are shorthand in which each digit is doubled, so #F80 is #FF8800. A fourth digit, or a fourth pair, is alpha: 00 is fully transparent and FF fully opaque, so #1E90FF80 is 128 ÷ 255, about 50.2% opaque.

rgb() and rgba() are the same function in current CSS: MDN calls rgba() an alias of rgb() and recommends writing rgb(). CSS Color 4 also allows spaces between the channels and the alpha after a slash, as in rgb(30 144 255 / 50%), and this converter reads and writes both forms.

HSL describes the same color as a hue angle, a saturation and a lightness, converted with the sample code in CSS Color 4. The tool rounds HSL to whole degrees and percents, so converting the rounded HSL back can land a step or two away in a channel: hsl(210, 100%, 56%) is rgb(31, 143, 255), next to #1E90FF's rgb(30, 144, 255).

channel = first digit × 16 + second digit    (00 → 0, FF → 255)
alpha   = alpha pair ÷ 255                     (80 → 128 ÷ 255 ≈ 0.502)

What are the HEX, RGB and HSL values of common CSS color names?

CSS named colors (HEX from CSS Color Module Level 4), converted by this tool; HSL rounded to whole degrees and percents
NameHEXrgb()hsl()
black#000000rgb(0, 0, 0)hsl(0, 0%, 0%)
white#FFFFFFrgb(255, 255, 255)hsl(0, 0%, 100%)
dodgerblue#1E90FFrgb(30, 144, 255)hsl(210, 100%, 56%)
rebeccapurple#663399rgb(102, 51, 153)hsl(270, 50%, 40%)
tomato#FF6347rgb(255, 99, 71)hsl(9, 100%, 64%)
coral#FF7F50rgb(255, 127, 80)hsl(16, 100%, 66%)
crimson#DC143Crgb(220, 20, 60)hsl(348, 83%, 47%)
orange#FFA500rgb(255, 165, 0)hsl(39, 100%, 50%)
gold#FFD700rgb(255, 215, 0)hsl(51, 100%, 50%)
seagreen#2E8B57rgb(46, 139, 87)hsl(146, 50%, 36%)
teal#008080rgb(0, 128, 128)hsl(180, 100%, 25%)
slategray#708090rgb(112, 128, 144)hsl(210, 13%, 50%)

How to convert a HEX color to RGB

  1. 1
    Enter a colorType or paste a HEX code such as #1E90FF, 1e90ff, #F80 or #1E90FF80, or an rgb(), rgba(), hsl() or hsla() value.
  2. 2
    Check the swatchThe swatch shows the color. A color with alpha is shown twice: with its transparency and fully opaque.
  3. 3
    Copy the form you needEach line has its own copy button: HEX, rgb(), rgba(), hsl() and the CSS Color 4 space syntax.

Frequently asked questions

What is #FFFFFF in RGB?
rgb(255, 255, 255), which is white: every channel is FF, the maximum of 255. #000000 is rgb(0, 0, 0), black.
How do I convert RGB to HEX?
Write each channel from 0 to 255 as two base-16 digits and join them: 30 is 1E, 144 is 90 and 255 is FF, so rgb(30, 144, 255) is #1E90FF. Paste any rgb() value into the converter to get its HEX code.
How do I add transparency to a HEX color?
Add a two-digit alpha pair to the end: #1E90FF80 is #1E90FF at 128 ÷ 255, about 50% opacity, and #1E90FF00 is fully transparent. The same color in the CSS Color 4 space syntax is rgb(30 144 255 / 50.2%).
What is the difference between rgb() and rgba()?
In current CSS there is none: rgba() is an alias of rgb(), and both accept an alpha value, so rgba(30, 144, 255, 0.5) and rgb(30 144 255 / 50%) are the same color. MDN recommends writing rgb().
Why does converting HSL back to HEX give a slightly different color?
HSL is usually rounded to whole degrees and percents, and those rounded values don't fall exactly on the 256 steps of each RGB channel. hsl(210, 100%, 56%) converts to #1F8FFF, a step or two from #1E90FF, so keep the HEX or rgb() value when the exact color matters.

Sources

Related tools

See all 73 free tools

Need this, but tailored to your brand?

We design UI, UX, and interfaces that feel as good as they look.

Built by CountryDevs · No signup · No ads · We count visits, never what you enter