Color Converter

Type a color as HEX, rgb(), hsl() or a CSS color name such as rebeccapurple, and get the same color in HEX, RGB, HSL, HSV and OKLCH, each with a copy button. A second field checks the WCAG 2.x contrast ratio against a background color, so you can see whether a text color passes AA or AAA before you ship it. Everything is calculated in your browser.

How to use the Color Converter

  1. Type or paste a color into Input color, or pick one with the swatch. Accepted forms: #abc, #aabbcc, #aabbccdd, rgb(37, 99, 235), rgb(37 99 235 / 50%), hsl(221.2, 83.2%, 53.3%), and any CSS color name your browser knows.
  2. The table updates as you type. Each row has a Copy button. Short hex expands: #abc is #aabbcc, which is rgb(170, 187, 204).
  3. Put your background color in Contrast against (white by default) to see the ratio and which WCAG levels it passes.

Example: #2563eb converts to rgb(37, 99, 235), hsl(221.2, 83.2%, 53.3%) and hsv(221.2, 84.3%, 92.2%). Pure red #ff0000 is oklch(62.80% 0.2577 29.23) and pure blue #0000ff is oklch(45.20% 0.3132 264.05).

If a value cannot be parsed, the tool says so instead of guessing. Colors with transparency are converted as if they were opaque, and a note tells you the alpha was ignored.

HEX, RGB, HSL, HSV and OKLCH: what each one is for

HEX and RGB are the same thing written two ways: three channels, red, green and blue, from 0 to 255. #2563eb is rgb(37, 99, 235). They describe how much light each sub-pixel emits, which is exact but hard to reason about: making a color "a bit darker" in RGB means changing all three numbers.

HSL (hue, saturation, lightness) and HSV (hue, saturation, value) rearrange the same RGB cube into a cylinder. Hue is an angle (0 is red, 120 green, 240 blue), so rotating the hue keeps saturation and lightness. They are convenient for color pickers, but their "lightness" is not what the eye sees: hsl(60, 100%, 50%) (yellow) and hsl(240, 100%, 50%) (blue) have the same HSL lightness, yet yellow looks far brighter.

OKLCH fixes that. It is the polar form of OKLab, a color space published by Björn Ottosson in 2020 and adopted by CSS Color 4. L is perceived lightness (0% to 100%), C is chroma (0 for greys, about 0.3 for the most vivid screen colors) and h is the hue angle. Equal steps in L look like equal steps in brightness, which is why design systems build palettes in OKLCH: you can keep L fixed and swap the hue to get colors of matching weight. In the two examples above, red has L 62.80% and blue only 45.20%, which matches how much darker pure blue looks. Greys have no hue, so the tool writes none for h, as CSS does: white is oklch(100.00% 0.0000 none).

The OKLCH values here are computed from sRGB with the published OKLab matrices. Because the input is an sRGB color, every result is inside the sRGB gamut.

Common use cases

  • Translating a design token: a designer hands you hsl() values and your CSS uses hex, or the other way round.
  • Starting an OKLCH palette from an existing brand hex: read off its L, C and h, then vary L for lighter and darker steps.
  • Checking text contrast before a release: body text needs 4.5:1 against its background for WCAG AA.
  • Reading a color from DevTools, which may show rgb() or a name, and getting the hex for a config file.

WCAG contrast: why one shade of grey matters

The ratio uses the WCAG 2.x relative-luminance formula, from 1:1 (same color) to 21:1 (black on white). The thresholds are 4.5:1 for normal body text at AA, 3:1 for large text (18pt, or 14pt bold) and for UI components, and 7:1 for body text at AAA (4.5:1 for large text at AAA).

Text color on #ffffffRatioAA body text (4.5:1)
#00000021.00:1pass
#7676764.54:1pass
#7777774.48:1fail

#767676 is the lightest neutral grey that still passes AA on white; one step lighter fails. That is why "light grey placeholder text" is a common accessibility bug. The check covers color contrast only: font size, weight and what sits behind the text are up to you.

Frequently asked questions

Why does the OKLCH hue say "none"?

Greys, black and white have zero chroma, so their hue angle is undefined. CSS Color 4 writes that as none; this tool does the same instead of printing an arbitrary angle.

Can I enter a color name like "tomato"?

Yes. Names, and any other syntax your browser understands, are parsed by the browser itself. The output is always numeric (HEX, RGB, HSL, HSV, OKLCH); the tool does not look up a name for a numeric color.

What happens to transparency?

Alpha is read (for example rgb(37 99 235 / 50%)) but the conversions and the contrast ratio use the opaque color, and a note says so. Contrast for a semi-transparent color depends on what is behind it, so check the blended color instead.

Is the contrast check WCAG 2 or APCA?

WCAG 2.x, the ratio that current accessibility guidelines and audits use. APCA, the candidate method for WCAG 3, is not calculated here.

Is my color sent anywhere?

No. All conversions run in your browser.
Embed this tool on your site

Free to embed, no attribution required (but appreciated). Paste this where you want the tool to appear: