Free tool

HEX to RGB converter

Convert a hex color code to RGB and HSL, or an RGB color to hex. Type a value in either field or use the color picker; both fields update as you type.

#1E90FF = rgb(30, 144, 255) = hsl(210, 100%, 56%)

How HEX and RGB color codes work

An RGB color mixes red, green and blue light, each from 0 to 255. A hex color code writes the same three numbers in hexadecimal: two digits per channel, so #RRGGBB. That is why every hex code converts to exactly one rgb() value and back. Hex codes are common in design tools and CSS; rgb() and rgba() are handy when you need to adjust a channel or add transparency. Starting from rgb() values instead? Use the RGB to HEX converter.

Common colors in HEX and RGB

ColorHEXRGBHSL
Black#000000rgb(0, 0, 0)hsl(0, 0%, 0%)
White#FFFFFFrgb(255, 255, 255)hsl(0, 0%, 100%)
Red#FF0000rgb(255, 0, 0)hsl(0, 100%, 50%)
Green#00FF00rgb(0, 255, 0)hsl(120, 100%, 50%)
Blue#0000FFrgb(0, 0, 255)hsl(240, 100%, 50%)
Yellow#FFFF00rgb(255, 255, 0)hsl(60, 100%, 50%)
Cyan#00FFFFrgb(0, 255, 255)hsl(180, 100%, 50%)
Magenta#FF00FFrgb(255, 0, 255)hsl(300, 100%, 50%)
Gray#808080rgb(128, 128, 128)hsl(0, 0%, 50%)
Orange#FFA500rgb(255, 165, 0)hsl(39, 100%, 50%)
Purple#800080rgb(128, 0, 128)hsl(300, 100%, 25%)
Dodger blue#1E90FFrgb(30, 144, 255)hsl(210, 100%, 56%)

HEX to HSL

HSL describes the same color as hue (0 to 360 degrees around the color wheel), saturation and lightness (both 0 to 100%). It is easier to adjust by hand: keep the hue and change the lightness to get a darker hover state or a lighter background tint. The converter shows the HSL value for every hex or RGB color you enter, so #1E90FF becomes hsl(210, 100%, 56%).

HEX vs RGB in CSS

Both work everywhere in modern CSS. Use hex for fixed brand colors because it is short and easy to copy between tools. Use rgb() with an alpha value, such as rgb(30 144 255 / 50%), when you need a transparent version of the same color. An 8-digit hex code (#1E90FF80) also adds alpha: the last two digits are the opacity. The converter reads 8-digit hex and uses the first six digits for the color.

Check these values on any live website

Traceo is a free Chrome extension that shows the real CSS on any page: hover an element to read its colors in HEX and RGB, font sizes in px and rem, spacing, and contrast, then record and share UI bugs with console and network logs.

FAQ

How do you convert a hex code to RGB values?

Split the six-digit hex code into three pairs and convert each pair from base 16 to base 10. For #1E90FF: 1E = 30, 90 = 144, FF = 255, so the color is rgb(30, 144, 255).

How do you convert RGB to HEX?

Convert each of the red, green and blue values (0 to 255) to a two-digit hexadecimal number and join them after a #. rgb(255, 165, 0) becomes FF, A5 and 00, so the hex code is #FFA500.

How do you convert HEX to HSL?

First convert the hex code to RGB, then find the largest and smallest of the red, green and blue values. Lightness is their average, saturation depends on how far apart they are, and hue depends on which channel is largest. The converter above does this automatically and shows the result as hsl(h, s%, l%).

What is a 3-digit hex code?

A shorthand where each digit is doubled: #FFF is #FFFFFF and #1E9 is #11EE99. The converter accepts both forms.

Are HEX and RGB colors the same color?

Yes. HEX and RGB are two notations for the same sRGB color values. #FF0000 and rgb(255, 0, 0) are the identical red, so you can use whichever your CSS or design tool prefers.

How do I find the HEX code of a color on a website?

Install the Traceo Chrome extension and hover the element. Traceo shows the colors the page actually renders in HEX and RGB, and can list the full color palette of the page.

More free tools