Free developer tool

Turn a HEX color into rgb() and hsl() you can paste into CSS

For front-end developers and designers moving a palette between tools. Pick a color or type its HEX code; the RGB and HSL equivalents are calculated in your browser and shown with Copy buttons.

Accepts #FFF and #FFFFFFCopy rgb() or hsl() in one clickLarge swatch for a visual check
HEX, RGB & HSL Converter

Type a HEX color or pick one. The swatch and the rgb() and hsl() values update as you type, each with a Copy button.

Runs on your device
HEX#6F4CFF
RGBrgb(111, 76, 255)
HSLhsl(252, 100%, 65%)

What the HEX, RGB & HSL Converter does

The HEX, RGB & HSL Converter takes one web color in hexadecimal notation and displays it three ways: normalized uppercase HEX (#6F4CFF), the rgb() function with each channel from 0 to 255 (rgb(111, 76, 255)), and the hsl() function with hue in degrees and saturation and lightness as whole percentages (hsl(252, 100%, 65%)). Each line has a Copy button.

You can type into the HEX field or use the native color picker beside it; the two stay in sync. Three-digit shorthand is expanded by doubling each digit, so #3AF becomes #33AAFF, and the leading # is optional. A large swatch below shows the color itself.

HSL is the useful form when you need a lighter or darker variant of a brand color: keep hue and saturation, move lightness. RGB is what canvas drawing, image processing code and many design tools expect.

How to use it

Enter or pick a color

Type a HEX value such as 336699 or #369 into the HEX color field, or use the Pick a color control to open your browser's picker.

Check the swatch

The large preview shows the exact color so you can confirm you typed the right value before copying anything.

Copy the format you need

Press Copy beside HEX, RGB or HSL. The strings are complete CSS values, for example rgb(51, 102, 153) or hsl(210, 50%, 40%).

How the RGB and HSL values are derived

Each pair of hex digits is parsed as a base-16 integer, giving red, green and blue from 0 to 255. For HSL the channels are scaled to 0 to 1; lightness is the average of the largest and smallest channel, saturation is the channel range divided by 1 minus the absolute value of (2L minus 1), and hue is 60 degrees times the position of the largest channel around the color wheel, as described in CSS Color Module Level 4.

Hue is rounded to the nearest whole degree, and saturation and lightness to the nearest whole percent. Those are the values most people type into a stylesheet, but the rounding means converting the hsl() value back to HEX can land one step away from the original on some channels.

A pure grey has no hue, so the tool reports hue 0 and saturation 0% for colors such as #808080, which displays as hsl(0, 0%, 50%).

Which notation to use where

The output uses the comma-separated legacy syntax, rgb(r, g, b) and hsl(h, s%, l%), which every browser accepts. Modern CSS also allows the space-separated form rgb(111 76 255) and an optional alpha after a slash; you can rewrite the copied value in that style if your codebase prefers it.

  • HEX: the compact form for stylesheets, design specs and HTML attributes; carries no transparency unless you use eight digits, which this tool does not output
  • rgb(): needed by canvas and image code, and easy to animate channel by channel
  • hsl(): the best form for building tints and shades from one hue, or for adjusting lightness until a color passes a contrast check

Checking the color before you ship it

A converted value is only as good as the color you started with. If the color will carry text, paste the HEX into the Color Contrast Checker to confirm it meets WCAG thresholds against its background, then come back here and move lightness in HSL until it passes.

Limits to know before you rely on it

  • Input is HEX only. You cannot type an rgb() or hsl() value and get HEX back; the conversion runs in one direction.
  • Alpha is not supported: four- and eight-digit hex codes, rgba() and hsla() are rejected, and the native color picker only produces opaque six-digit values.
  • HSL is rounded to whole degrees and whole percent, so a round trip through hsl() may differ from the original HEX by a small amount.
  • Hues just below 360 degrees (for example #FF0001) round to 360 rather than 0; CSS treats the two as the same angle.
  • Only sRGB colors are handled. There is no support for display-p3, lab(), oklch() or other wide-gamut notations.

Questions people ask about the HEX, RGB & HSL Converter

What does #3AF expand to?

#33AAFF. Three-digit shorthand repeats each digit, so 3 becomes 33, A becomes AA and F becomes FF. The tool shows the expanded uppercase form on the HEX line and uses it for the RGB and HSL results.

Can I convert rgb(51, 102, 153) to HEX here?

Not directly, because the input field reads HEX only. You can do it by hand: write each channel in base 16 (51 is 33, 102 is 66, 153 is 99) to get #336699, or run each channel through the Number Base Converter.

Why does my HSL value not convert back to exactly the same HEX?

Hue, saturation and lightness are rounded to whole numbers for readability. Rounding 64.9% lightness to 65% shifts the color slightly, so the reverse conversion can be off by one or two on a channel. Keep the HEX as the source of truth.

Does uppercase or lowercase HEX matter?

No. #6f4cff and #6F4CFF are the same color in CSS. The tool normalizes to uppercase on output; lowercase it after copying if your style guide prefers that.

Can I include transparency such as #6F4CFF80?

No. Eight-digit and four-digit hex with alpha are rejected with an error message, as are rgba() and hsla(). Convert the opaque six-digit part here and add the alpha yourself in the modern rgb(r g b / a) syntax.

Is the color sent anywhere?

No. Parsing and conversion are a few arithmetic operations performed by JavaScript in your browser, and the page stores nothing.

Sources and further reading