Skip to content
cliplimeClipLime

Convert colors between HEX, RGB, HSL and CMYK

Pick or type a color, see every format at once, check its contrast and copy the CSS.

Runs in your browser, nothing is sent anywhere

Pick a color

#c5ec43

Closest CSS name: yellowgreen #9acd32

Alpha, from fully see-through to solid

100%

All formats

HSL, HSV and CMYK precision

HEX

#c5ec43

RGB

rgb(197, 236, 67)

Each channel runs from 0 to 255.

HSL

°
%
%

hsl(74, 82%, 59%)

Hue in degrees, saturation and lightness in percent.

HSV (HSB)

°
%
%

hsv(74, 72%, 93%)

The model most color pickers use. Not valid CSS.

CMYK

%
%
%
%

cmyk(17%, 0%, 72%, 7%)

A simple screen to print formula. Real printing needs a color profile, so expect a shift.

HSL, HSV and CMYK are rounded to whole numbers, so converting them back can land one step away from the original. Pick decimals to see more exact values.

Contrast with white and black

With white

1.36:1

Aaon white
Aawhite
  • FailsAA text
  • FailsAA large text
  • FailsAAA text
  • FailsAAA large text
  • FailsIcons and borders

With black

15.45:1

Aaon black
Aablack
  • PassesAA text
  • PassesAA large text
  • PassesAAA text
  • PassesAAA large text
  • PassesIcons and borders

Text on this color reads best in black (15.45:1).

Copy as CSS

Hex

color: #c5ec43;

RGB, comma separated

color: rgb(197, 236, 67);

RGB, space separated

color: rgb(197 236 67);

HSL, comma separated

color: hsl(74, 82%, 59%);

HSL, space separated

color: hsl(74 82% 59%);

Custom property

--color: #c5ec43;

At a glance

Formats
HEX (3, 4, 6 or 8 digits), RGB, HSL, HSV (also called HSB) and CMYK, plus the 148 CSS color names.
Ways in
Type or paste any of them, use the color picker, or edit a single channel such as the hue.
Opacity
An opacity slider gives 8 digit hex, rgba() and hsla() output.
Contrast
The WCAG contrast ratio against white and against black, with AA and AAA results for text, large text and icons.
CSS
Copy-ready lines in comma and space separated syntax, and a custom property.
Closest name
The nearest of the 148 CSS color names, measured with CIE76 color difference.
Privacy
Runs in your browser. The colors you enter are not sent anywhere.

How to do it

  1. 1

    Pick or type a color

    Use the picker, or paste a value such as #3b82f6, rgb(59, 130, 246), hsl(217 91% 60%) or a name like tomato.

  2. 2

    Read or edit every format

    HEX, RGB, HSL, HSV and CMYK update together. Change any channel and the rest follow. Choose decimals if you want more exact HSL, HSV and CMYK values.

  3. 3

    Check contrast, then copy

    See whether white or black text reads better on the color, then copy a CSS line or the whole block.

How the formats relate

Every format here describes the same on-screen sRGB color in a different way:

  • HEX is RGB written in base 16. #RRGGBB has one pair of digits per channel, from 00 to ff. The shorthand #abc means #aabbcc, and an 8 digit form adds opacity at the end.
  • RGB gives red, green and blue as numbers from 0 to 255. It is how screens mix light, so it is the most direct format.
  • HSL gives a hue in degrees on the color wheel (0 is red, 120 green, 240 blue), then saturation and lightness in percent. At 50% lightness you get the pure color, so lighter and darker shades are just a change to L.
  • HSV, or HSB, uses the same hue but replaces lightness with value, the brightness of the strongest channel. Most graphics software color pickers work this way. CSS cannot read it.
  • CMYK describes ink on paper: cyan, magenta, yellow and black. A proper screen to print conversion depends on the printer and paper profile. This page uses the simple formula, which is a good first estimate and not a proof color.

Contrast and accessibility

The WCAG 2 contrast ratio compares the relative luminance of two colors and runs from 1:1 (no difference) to 21:1 (black on white). The thresholds that accessibility checks use are:

  • 4.5:1 for normal text at level AA, and 7:1 at level AAA.
  • 3:1 for large text (about 24 px, or 18.7 px bold) at AA, and 4.5:1 at AAA.
  • 3:1 for icons, borders and other parts of an interface that you need to see.

The default color on this page, a light lime, is a useful example: against black the ratio is 15.45:1 and against white only 1.36:1. It works as a background for dark text and fails as text on white. The ratio is symmetrical, so the same number applies to white text on that lime.

A ratio just under a limit is never rounded up to look like a pass. WCAG 3 drafts propose a different method, but WCAG 2 ratios are what audits and accessibility rules use today.

Writing colors in CSS

Browsers read hex, rgb(), hsl() and named colors. The space separated form, such as rgb(197 236 67 / 50%), works in current browsers, and the older comma form, rgba(197, 236, 67, 0.5), works everywhere. Use whichever your project already uses.

HSL is handy for themes: keep the hue, change the lightness for hover and disabled states. HSV and CMYK have no CSS function in today's browsers, so those values are for design tools and print, not stylesheets.

When you convert through HSL, HSV or CMYK with whole numbers, the result can land one step away from the original, because those models round to a coarser grid than 256 steps per channel. Choose decimals to avoid it.

Questions people ask

How do I convert HEX to RGB?

Split the code into three pairs and convert each pair from base 16 to a number: for #c5ec43, c5 is 197, ec is 236 and 43 is 67, so it is rgb(197, 236, 67). The HEX to RGB converter shows the working for any code.

What is the difference between HSL and HSV?

They share the hue. HSL's lightness runs from black through the pure color to white, while HSV's value runs from black to the pure color, so full value and full saturation is the vivid color itself. Use HSL in CSS and HSV when matching a design tool's picker.

Why does the CMYK differ from my design software?

Because converting from RGB to CMYK needs a color profile for the ink and paper, and this page uses a plain formula without one. Print work should be converted in software that uses a profile.

What contrast ratio do I need for text?

At least 4.5:1 for normal text to meet WCAG level AA, and 3:1 for large text. Level AAA asks for 7:1 and 4.5:1. The check on this page shows each result against white and black.

Can I enter a color with transparency?

Yes. Type an 8 digit hex such as #c5ec4380, an rgba() or hsla() value, or use the opacity slider. The outputs then include the alpha, and the contrast is worked out for how the color looks over white or black.

Are my colors sent anywhere?

No. The conversion is plain arithmetic in your browser, and nothing is uploaded or stored.