Color Converter

Type a color in any one field, or use the picker, and the other two formats update with a live preview.

How HEX, RGB and HSL describe the same color

Every value this converter produces describes one color in the sRGB color space, the space browsers use by default. HEX and RGB are the same three numbers written in different bases: a red, a green and a blue channel from 0 to 255. HSL re-maps those channels onto a cylinder of hue, saturation and lightness, which is why #2563eb, rgb(37, 99, 235) and hsl(217, 83%, 53%) all paint the same blue. The CSS Color Module Level 4 defines all three notations, along with newer ones such as oklch() that this tool does not output.

HEX writes each channel as two hexadecimal digits, 00 to ff, after a hash sign. When both digits of every pair match, the three-digit short form works: #abc expands to #aabbcc. CSS also allows four- and eight-digit forms that add an alpha channel, as described in MDN's hex color reference; this converter reads only the three- and six-digit forms.

RGB states the same channels in decimal, which is closer to how a display mixes red, green and blue light for each pixel. You will reach for it mainly when you need transparency, because rgb(37 99 235 / 50%) or the older rgba(37, 99, 235, 0.5) add an alpha value that HEX makes harder to read.

HSL is the notation to use when you want to derive colors from one another. Hue is an angle on the color wheel: 0 for red, 120 for green and 240 for blue. Saturation runs from 0% (gray) to 100% (fully saturated) and lightness from 0% (black) through 50% (the pure hue) to 100% (white); see MDN's hsl() reference. Keep the hue, lower the lightness by ten points, and you have a hover shade that still reads as the same color.

What this converter accepts and what it leaves out

  • Input formats: #rgb or #rrggbb with or without the hash, rgb() with comma-separated numbers, and hsl() with comma-separated numbers; the percent signs are optional. The space-separated syntax, rgb(37 99 235), is not parsed.
  • Rounding: hue, saturation and lightness are rounded to whole numbers, so converting a color to HSL and back can shift a channel by one unit. The HEX and RGB fields are always exact.
  • No alpha channel: rgba(), hsla() and eight-digit HEX are not understood. Convert the opaque color here and add the alpha value in your stylesheet.
  • No named colors or wide gamuts: rebeccapurple, oklch(), lab() and display-p3 values are outside its scope. The picker is the browser's own <input type="color"> control, so it looks different on each operating system.

Putting the values to work in CSS

  • Store colors once: declare --brand: #2563eb; on :root and use var(--brand) everywhere, so a rebrand is a one-line change.
  • Build shades in HSL: keep hue and saturation fixed and step the lightness, for example 53% for the base, 43% for hover and 93% for a tinted background.
  • Check contrast before you ship: WCAG 2.1 asks for a contrast ratio of at least 4.5:1 between normal text and its background at Level AA, and 3:1 for large text (success criterion 1.4.3). A pleasant blue on gray often fails; test the pair, not the color alone.
  • Match the source: design tools usually hand over HEX, so paste that here when you need the RGB or HSL equivalent for a gradient or an animation.

Frequently Asked Questions

What is the difference between HEX and RGB?

Only the number base. #ff0000 and rgb(255, 0, 0) are the same red: ff in hexadecimal is 255 in decimal. HEX is shorter and is what most design tools copy to the clipboard; RGB is easier to read and to animate, and its functional form takes an alpha value.

Why do designers prefer HSL?

Because it separates what the color is (hue) from how strong and how light it is. A darker shade means lowering lightness, a muted version means lowering saturation, and the hue stays put. Doing the same in HEX or RGB means changing all three channels by different amounts and checking the result by eye.

Can every color be written in all three formats?

Yes. All three notations cover the same sRGB gamut of 256 x 256 x 256, or 16,777,216, colors, and every value in one has an exact counterpart in the other two. The only loss in this tool is the rounding of HSL to whole numbers described above.

Is my color sent to a server?

No. The conversion is a few lines of JavaScript in this page, and the values you type stay in your browser. The page does load the site's shared analytics script, which counts visits; it does not see the colors you enter.

Related tools: pick a color out of a screenshot or photo with the Image Color Picker, turn a logo into icon files with the Favicon Generator, and fill a mockup with the Lorem Ipsum Generator.