UtilityPilot.Find a tool

Web & Publishing

HEX, RGB and HSL Color Converter

Convert HEX, RGB and HSL color notation with a visible swatch. Keep supported alpha values and see the rounding applied to sRGB channels.

Processed in your browserPrivacy details ↗

1 MiB per input

Ready when you are

No sign-up. No upload.

How to use this tool

  1. Enter a HEX code, rgb() or hsl() value.
  2. Convert and inspect the equivalent notations and swatch.
  3. Copy the value required by your editor or stylesheet.

How the operation works

HEX expands short forms to byte channels. RGB values and percentages are converted to sRGB channels; HSL hue wraps around a 360-degree circle. RGB outputs round to whole bytes, and HSL uses two decimal places. Alpha is retained and included in the HEX output when it is less than one.

How the three notations relate

HEX is a compact base-16 spelling of sRGB channels: #ff8800 is red 255, green 136, blue 0. Short form #f80 expands each digit to a doubled pair. RGB accepts integers 0–255 or percentages. HSL describes the same color as hue (0–360°), saturation (0–100%) and lightness (0–100%).

Conversions round for display: RGB outputs whole bytes; HSL uses two decimal places for saturation and lightness. Hue wraps at 360°. Alpha below 1 is retained and included in eight-digit HEX and in rgb()/hsl() alpha components.

Conversion examples

#f00      → #ff0000 · rgb(255 0 0) · hsl(0 100% 50%)
#0a0a0a   → rgb(10 10 10) · hsl(0 0% 3.9%)
#ff880080 → rgba(255 136 0, 0.502) · hsla(32 100% 50% / 0.502)

The swatch shows the converted color immediately. Copy the notation your editor or stylesheet expects. Two decimal places in HSL can still round when a design system stores one decimal—verify in the destination if exactness matters.

Transparency and compositing

Four-digit HEX (#rgbA) and eight-digit HEX (#rrggbbaa) carry alpha. rgb()/hsl() accept an alpha component or / syntax. Contrast checking requires opaque colors: composite transparent layers against their real background first, then check the resulting pair.

This converter is not a color-managed pipeline. It works in sRGB, not CMYK, Display-P3 or Rec.2020. Named CSS colors are not expanded here—enter HEX, rgb() or hsl() directly.

What this tool does not do

Invalid channel ranges, malformed HEX and unsupported notation are rejected rather than clamped silently. Wide-gamut values outside sRGB are not mapped. The tool does not pick palette harmonies, generate themes or certify accessibility—that is the contrast checker’s job for a specific text/background pair.

Sampling an image color is a separate step: use Image Color Picker when the source is a pixel, then convert the sampled HEX here if another notation is needed.

A worked example

#f00

#ff0000; rgb(255 0 0); hsl(0 100% 50%)

These are screen-color conversions, not a color-managed CMYK print conversion. Named colors, wide-gamut spaces and invalid channel ranges are rejected.

HEX, RGB and HSL describe the same colour differently

HEX writes each sRGB channel as a hexadecimal byte. RGB writes the same channels in decimal, and percentages are scaled to that range. HSL re-expresses the colour as hue, saturation and lightness: hue is an angle, saturation is distance from grey, and lightness runs from black through the colour to white. Alpha adds transparency in every notation.

HSL is convenient when you want to lighten or desaturate a colour, but it is not perceptually uniform. A 10% lightness change on a yellow and on a blue does not look like the same step. HEX and RGB are better when an exact channel value must be reproduced, such as a design token or a CSS variable.

Why a converted value can drift by one step

RGB channels are rounded to whole bytes for HEX output, and HSL is rounded to two decimals. A colour that arrives as fractional HSL can therefore return to a slightly different HEX value after a round trip. Hue also wraps at 360 degrees, so a computed hue below zero is moved into range.

These conversions are screen sRGB operations. They do not perform CMYK print conversion, colour-profile matching or wide-gamut mapping. For accessibility decisions, take the resulting opaque colours into Color Contrast Checker rather than judging contrast from HSL values.

Processing and privacy

Color Converter changes notation in the page; the entered colour values are not sent to a colour service. Input stays in browser memory until you reset or leave the page. Copy and download run only when you choose them. No tool input is sent to a processing service. Website pages and scripts still make ordinary hosting requests; the privacy policy separates those from tool processing.

Frequently asked questions

Can I enter transparency?

Yes—use four/eight-digit HEX or an alpha component in rgb()/hsl(). Contrast checking separately requires opaque colors.

Why does HSL show two decimal places?

Display rounding only. The underlying conversion uses full precision before formatting for the swatch and copy fields.

Does this convert print (CMYK) colors?

No. All conversions are sRGB screen colors. A print workflow needs a color-managed application with the correct profile.

Are named colors like “rebeccapurple” supported?

Enter HEX, rgb() or hsl() instead. Named-color expansion is not part of this converter.

Can I use the result in a contrast check?

Yes. Copy the opaque HEX into the foreground or background field of the Contrast Checker.

Does a HEX to HSL round trip always return the same colour?

No. Rounding to whole RGB bytes and two-decimal HSL can shift a channel by one step, especially from fractional input.

Can I convert CMYK, named colours or wide-gamut spaces?

No. The converter accepts sRGB HEX, rgb() and hsl() notation only and rejects other colour spaces.

How this tool was checked

Color Converter was checked with shorthand and full HEX, RGB percentages, HSL hue wrapping, alpha values, out-of-range channels and malformed notation. See the testing method or report a failure.