Web & CSS

Color Converter

Enter any CSS color, from a HEX code to a color name, and get HEX, RGB, HSL and CMYK values with a live swatch and color picker.

HEX
RGB
HSL
CMYK
Ready.

What it does

Type a color in almost any CSS format and see it in the others. Your browser's CSS parser reads the input, so it accepts the same things a stylesheet does: #f80, #ff8800, rgb(255 136 0), hsl(32 100% 50%), rebeccapurple and semi-transparent forms such as rgba(255, 0, 0, 0.5).

Formats

  • HEX is the common web notation; an 8-digit form includes transparency.
  • RGB gives red, green and blue from 0 to 255.
  • HSL gives hue in degrees, then saturation and lightness in percent, which is easier for making lighter or darker variants.
  • CMYK is a simple mathematical conversion for reference. Real print colors depend on ink and paper profiles.

Example

#3b82f6 converts to rgb(59, 130, 246), hsl(217, 91%, 60%) and cmyk(76%, 47%, 0%, 4%). Typing rgb(59 130 246 / 50%) gives the same colour at half opacity, shown as the 8-digit HEX #3b82f680 and as rgba() and hsla(). Use the picker to choose a colour visually and copy any row with its Copy button. Once you have a text and background pair, check it with the Color Contrast Checker.

Limits

  • Input needs the # for HEX, so #fff works and fff does not.
  • Only colours that resolve to sRGB are converted. Newer spaces such as oklch(), lab() and color() are reported as unreadable instead of being approximated. Values outside the 0 to 255 range, like rgb(300, 0, 0), are clamped.
  • currentcolor, inherit and similar keywords are rejected because they depend on the page they are used in.
  • CMYK ignores transparency, so transparent shows cmyk(0%, 0%, 0%, 100%) while the HEX row shows alpha 00.

To tidy a stylesheet that uses these values, paste it into the CSS Formatter & Minifier.

Examples

  • rebeccapurple gives HEX #663399, RGB rgb(102, 51, 153), HSL hsl(270, 50%, 40%) and CMYK cmyk(33%, 67%, 0%, 40%).
  • hsl(32 100% 50%) (the modern space-separated syntax) gives #ff8800, rgb(255, 136, 0) and cmyk(0%, 47%, 100%, 0%).
  • #ff000080 is a red with an alpha value of 80 in hexadecimal, which is half transparent, so the tool shows rgba(255, 0, 0, 0.5) and hsla(0, 100%, 50%, 0.5).

You can type a colour name, a HEX code of 3, 4, 6 or 8 digits, or an rgb() or hsl() value. A value that cannot be read gives a clear message: “Could not read that colour. Try a HEX code, rgb(), hsl() or a colour name.”

Which format should I use?

  • HEX is the most common choice in CSS, design tools and brand guides.
  • RGB is the format of screens: three channels from 0 to 255.
  • HSL is easiest to adjust by hand. Change the lightness to make a shade, or the saturation to mute a colour.
  • CMYK is calculated from RGB with the standard formula. Real printing depends on the ink, the paper and the printer profile, so treat it as a starting point.

To check that two colours are readable together, use the Color Contrast Checker.

Frequently asked questions

What is the 8-digit HEX code?

The last two digits are the alpha channel, the opacity. 00 is fully transparent and ff is fully opaque, so 80 is about 50%.

Why does the converted value differ slightly from my design tool?

Rounding. The tool shows whole numbers for RGB and rounded percentages for HSL and CMYK.

Is my colour sent to a server?

No. The conversion runs in your browser.

Privacy

This tool runs entirely in your browser. What you enter is processed on your device and is not sent to a server.

Share this tool

Your data is not included in this link.