Skip to content

Color Converter

Convert colors between HEX, RGB, HSL and HSV with a live picker and preview, and check the WCAG contrast ratio against white and black text.

  • Free, no sign-up
  • Runs in your browser
  • Developer
3, 4, 6 or 8 digits, with or without #. The last two of 8 digits are the alpha.
RGB (0–255)
HSL
HSV / HSB
1 is fully opaque, 0 fully transparent. All fields update as you type.

Read the guide HEX, RGB and HSL Color Codes Explained

How to use the color converter

Edit any field and all the others update as you type:

  • HEX: 3, 4, 6 or 8 hex digits, with or without the # sign. With 4 or 8 digits the last part is the alpha (transparency).
  • Picker: choose a color visually with your system color picker.
  • RGB: red, green and blue from 0 to 255.
  • HSL: hue in degrees (0–360), saturation and lightness in percent.
  • HSV / HSB: hue, saturation and value (brightness) in percent, as used by many design apps.
  • Alpha: from 0 (fully transparent) to 1 (fully opaque).

The result card shows a preview with sample text in white and black, the CSS values ready to copy, and the contrast ratio against white and black. The details card lists every WCAG level as pass or fail.

How the conversions work

HEX is simply RGB written in base 16: each pair of digits is one channel from 00 to FF. HSL and HSV both describe the hue as an angle on the color wheel. HSL then measures lightness, where 50% is the pure color, 0% black and 100% white. HSV measures value, where 100% is the brightest version of the color.

RGB values are rounded to whole numbers, and HSL and HSV to one decimal place.

Contrast ratio

WCAG 2 first converts each color to its relative luminance, a number from 0 for black to 1 for white that follows how bright the eye perceives each channel. The contrast ratio is (L1 + 0.05) / (L2 + 0.05), where L1 is the lighter color. It ranges from 1:1 to 21:1.

The thresholds are 4.5:1 for AA and 7:1 for AAA with normal text, and 3:1 for AA and 4.5:1 for AAA with large text (about 24 px, or 19 px bold). Interface parts such as icons and input borders need 3:1.

Worked example

Take #336699. In RGB that is 51, 102, 153. The largest channel (blue) gives a hue of 210°, and the result is hsl(210, 50%, 40%) or hsv(210, 66.7%, 60%).

Its relative luminance is about 0.125. Against white the ratio is 1.05 / 0.175 ≈ 5.99:1, so white text on this blue passes AA but not AAA. Against black it is only 3.50:1, enough for large text only.

Good to know

  • Ratios are cut, not rounded, to two decimals, because WCAG does not allow rounding up: 4.499 fails AA.
  • A transparent color is blended with each background before its contrast is measured.
  • The picker cannot show transparency, so it displays the color as if it were fully opaque.

Frequently asked questions

What is the difference between HSL and HSV?

Both use the same hue angle. In HSL, 100% lightness is always white and the pure color sits at 50%. In HSV, 100% value is the brightest form of the color, and white needs 0% saturation. Design apps often call HSV HSB.

What do the last two digits of an 8-digit HEX code mean?

They are the alpha channel. FF is fully opaque, 80 is about 50% transparent and 00 is invisible. Modern browsers accept 8-digit HEX colors in CSS.

What contrast ratio do I need for accessible text?

WCAG level AA asks for at least 4.5:1 for normal text and 3:1 for large text. Level AAA asks for 7:1 and 4.5:1. Meeting AA is the usual target for websites and apps.

Why does the color look slightly different after converting?

RGB channels must be whole numbers, so a color typed in HSL or HSV is rounded to the nearest RGB value. The difference is at most half a step out of 255 per channel and cannot be seen.