Text & code / Guides

HEX, RGB and HSL: the same color in different notation

A CSS color can be written with hex digits, channel numbers or hue coordinates. The numbers change while the intended sRGB color can stay the same.

Three descriptions of an sRGB color

A six-digit HEX color packs red, green and blue channel values into pairs of hexadecimal digits. RGB writes those same three channels as decimal numbers from 0 through 255 in these tools. HSL rearranges the same sRGB color into hue, saturation and lightness coordinates. It is useful when you want to reason about a color family, but lightness is a parameter of this model rather than a direct measure of perceived brightness. HEX and RGB are two notations for channel values; HSL requires calculation. All three can specify a matching display color when conversion is performed consistently. The MultiVerto tools here handle opaque colors and their displayed input formats, not every possible CSS color syntax.

Work through a muted blue

Take #336699. Its pairs are 33, 66 and 99 in hexadecimal, which become decimal 51, 102 and 153. The HEX-to-RGB tool therefore shows rgb(51, 102, 153). Converting those RGB values to HSL gives hsl(210, 50%, 40%) in the tool's rounded display. Hue 210 degrees lies in the blue region; saturation 50% and lightness 40% describe this particular HSL coordinate. Enter #336699 below and then paste the RGB result into the linked RGB-to-HSL tool. Reverse the route with HSL-to-RGB and RGB-to-HEX. For this example, the simple values return to the original six-digit color.

One opaque sRGB color, three coordinate systems.
  1. HEX #336699 → channels 33 66 99
  2. RGB rgb(51, 102, 153)
  3. HSL hsl(210, 50%, 40%)

Round trips and precision

The HEX pairs identify integer channel values exactly. An HSL representation of arbitrary RGB channels may require more fractional digits than a short display shows. MultiVerto rounds displayed HSL components to two decimal places and the reverse converter rounds RGB channels to whole integers. For many inputs a round trip stays visually close, but a tiny change of one channel can occur. Keep the original HEX or RGB token if an exact machine-readable color is part of a design system. A shorthand three-digit HEX value expands each digit, so #369 becomes #336699; it is not three decimal numbers. This tool does not accept alpha transparency in the sample converters, so a translucent color needs a separate workflow.

Conversion is not an accessibility test

The same numeric color may look different against different backgrounds or on different devices. HSL lightness does not tell you whether white or black text meets a contrast requirement. Contrast depends on two colors and the accessibility formula, not on one color's HSL percentage alone. If the color is used for text, test the actual foreground and background pair against the relevant WCAG criterion. Also check hover, focus and disabled states where other colors may appear. The conversion tools help you preserve a notation across CSS, a design token file or an API response; they do not choose an accessible palette automatically. Do not infer readability from a single converter output.

A practical design-token workflow

Choose one canonical token, such as #336699, and record where it is used. Convert it to RGB when an interface asks for channel numbers, or to HSL when adjusting hue and saturation deliberately. After editing HSL, convert the new value back to RGB or HEX and save the result as a new token rather than silently overwriting the old one. Compare rendered swatches in the real layout, then run the contrast check with the actual neighboring colors. Keep alpha and wide-gamut CSS colors outside this simple three-channel comparison unless the destination explicitly supports them. A clear source token plus tested variants makes later maintenance easier than hand-copying three unrelated color strings.

Try the converter

Convert #336699 to RGB, then follow the linked HSL tool.

Convert a #RGB or #RRGGBB color into three RGB channel values.

Open full converter

More guides

Conversion guides

Explore guides