HEX, RGB and HSL Color Converter

About this calculator

Paste a HEX, RGB or HSL color. Convert it into the other CSS formats, including its opacity.

Enter 3, 4, 6 or 8 HEX digits. Example #369 or #336699.

Embed this calculator

Paste this code into a Custom HTML block on your site. The calculator fits the width of the block. Adjust the height in the code if you want more room for results.

Find this widget in the publisher directory

How do you convert HEX to RGB?

A six-digit CSS HEX color has two hexadecimal digits per red, green and blue channel. Convert each pair to a number from 0 through 255. For example, #336699 gives 51 red, 102 green and 153 blue, or rgb(51 102 153). In a three-digit HEX color, repeat each digit first. So #369 is also #336699.

How do you convert RGB to HSL?

RGB names the red, green and blue components of an sRGB color. HSL describes the same color with hue in degrees and saturation and lightness in percentages. Normalize the RGB components from 0 through 1. Lightness is the midpoint of the largest and smallest component. Hue depends on the dominant component, while saturation describes the spread relative to the lightness. The W3C CSS Color 4 HSL specification documents both directions.

For #336699, the result is hsl(210 50% 40%). For a gray where all three RGB components are equal, saturation is zero and hue has no visual effect. The converter displays that hue as zero.

How is transparency handled?

Alpha means opacity. In rgb(255 0 0 / 50%), the alpha is 0.5. CSS HEX stores that opacity as a byte. The closest byte is 128, so the HEX result is #FF000080. That byte represents 128/255, about 50.196%. The RGB and HSL results keep 0.5 before display rounding. In four-digit HEX, the fourth digit is opacity and is doubled, just like the three color digits.

Which color inputs are supported?

Use 3, 4, 6 or 8 HEX digits, RGB channels as numbers or percentages, or HSL with hue in degrees and two percentages. CSS functions may use commas or spaces with a slash before alpha. A pasted RGB or HSL value may also omit the function wrapper if the format is selected. Values outside channel ranges are rejected. The tool covers sRGB color notation and does not convert named colors, wide-gamut colors, CMYK profiles, or design-specific color accessibility.

Frequently asked questions

What is the RGB value of #FFFFFF?
It is rgb(255 255 255), or white.
What is the difference between #RGB and #RGBA?
The extra digit in #RGBA is the opacity. Each digit is expanded into a pair, so #F008 expands to #FF000088.
Can I paste an rgba() or hsla() value?
Yes. Choose RGB or HSL and paste the matching function. Alpha can be a number between 0 and 1 or a percentage.
Why can a HEX conversion change a value slightly?
HEX uses whole bytes. RGB channels or opacity between byte steps round to the nearest representable byte.

Formulas and sample results on this page were checked against independent references. Page last reviewed or updated . How we verify calculators. Project led by Shaun Connell.