Color Converter & Contrast Checker

Paste any CSS color to get it in HEX, RGB, HSL, HWB and OKLCH, then check a text and background pair against the WCAG contrast rules. If a pair fails, the checker finds the nearest shade of your text color that passes.

Convert a color

Read as hex.

  • HEX#42a4c7
  • HEX + alpha#42a4c7ff
  • RGBrgb(66, 164, 199)
  • HSLhsl(195.8, 54.3%, 52%)
  • HWBhwb(195.8 25.9% 22%)
  • OKLCHoklch(67.55% 0.1036 225.22)
  • OKLaboklab(67.55% -0.073 -0.0735)
  • Nearest namecadetblue (#5f9ea0)

Check contrast

Read as hex.

Read as hex.

4.48:1contrast

  • FailAA, normal textWCAG 1.4.3, body text4.5:1
  • PassAA, large text18pt (24px), or 14pt (about 18.7px) bold3:1
  • FailAAA, normal textWCAG 1.4.6, enhanced7:1
  • FailAAA, large textEnhanced, large text4.5:1
  • PassUI and graphicsWCAG 1.4.11, icons, borders, focus rings3:1

Normal text at 16px. The quick brown fox jumps over the lazy dog.

Large text at 24px

Bold text at 18.7px counts as large

A button outline

Closest text color that reaches 4.5:1 (AA)

Darker#767676 (4.54:1)

Lighter: not possible. Even white only reaches 1.00:1 against this background.

Closest text color that reaches 7:1 (AAA)

Darker#595959 (7.00:1)

Lighter: not possible. Even white only reaches 1.00:1 against this background.

Runs entirely in your browser. Nothing you type or upload is sent to a server.

What the color formats mean

Every format on this page describes the same thing, an amount of red, green and blue light, in a different way. HEX writes the three amounts as pairs of base-16 digits from 00 to FF, so #42a4c7 is red 66, green 164, blue 199. An optional fourth pair is opacity, and the three- and four-digit forms double each digit. RGB writes the same numbers in decimal. Both are exact but hard to adjust by eye: making a color slightly darker means changing all three numbers by different amounts.

HSL and HWB were added to CSS to fix that. HSL gives a hue as an angle on the color wheel, then saturation and lightness as percentages; HWB gives a hue, then how much white and black to mix in, which is how a painter thinks. Both are easier to tweak, but their lightness is a formula, not a perception. Pure yellow and pure blue are both 50% lightness in HSL, yet yellow looks far brighter.

OKLCH and its rectangular twin OKLab solve that. Published by Björn Ottosson in 2020 and adopted in CSS Color 4, they are built from measurements of how people perceive color, so a color at 60% lightness looks about as light as any other at 60%, whatever its hue. That makes OKLCH the best format for building palettes, generating hover states, or darkening a brand color for text without it turning muddy. It can also describe colors brighter than a standard sRGB monitor shows, which is why a vivid OKLCH value sometimes has to be mapped to the nearest color a hex code can hold.

How WCAG measures contrast

The Web Content Accessibility Guidelines compare the relative luminance of two colors: each channel is converted from its encoded value to linear light, then weighted by how sensitive the eye is to it (green counts for about 72%, red 21% and blue 7%). The ratio is (lighter + 0.05) divided by (darker + 0.05), which runs from 1:1 for two identical colors to 21:1 for black on white.

WhatLevel AALevel AAA
Normal text4.5:17:1
Large text (24px, or about 18.7px bold)3:14.5:1
Icons, input borders, focus rings, chart lines3:1Not defined

AA is the level that accessibility laws and audits usually point to: Section 508 in the United States references WCAG 2.0 AA, and the European standard EN 301 549 references WCAG 2.1 AA. The rules do not apply to logos, to purely decorative text, or to controls that are disabled.

Thresholds are not rounded

#777777 on white is 4.48:1 and fails AA. #767676, one step darker and impossible to tell apart, is 4.54:1 and passes.

Some checkers round to one decimal and report 4.5:1 for colors that do not actually reach it. This one decides on the exact figure. Transparent colors are measured as they appear: a translucent text color is blended with its background first, exactly as the browser draws it, and the blended color is what gets measured.

Fixing a pair that fails

When the text color falls short, the usual fix is to keep its hue and change only its lightness. The checker does that in OKLCH, holding hue and chroma steady and searching for the closest lightness, in each direction, that reaches 4.5:1 and 7:1. The result still reads as the same color, just deeper or paler. A common pattern is to keep a light brand color for large headings and backgrounds, where 3:1 is enough, and use its darker shade for body text and links. If no shade gets there, the message says why: either even black or white falls short against that background, or the text is too transparent to ever reach the ratio.

Contrast is not only a web concern. A QR code needs strong contrast between its dark modules and the light background to scan reliably, and a social share card in the link preview checker is often viewed small, on a phone, in sunlight. For photos and other images, see the image compressor.

Frequently Asked Questions

What contrast ratio does WCAG AA require?
4.5:1 for normal text and 3:1 for large text, which WCAG defines as at least 18 point (24px) or 14 point (about 18.7px) bold. Since WCAG 2.1, icons, input borders, focus indicators and the parts of a chart you need to read must also reach 3:1 against what is next to them. Level AAA raises the text figures to 7:1 and 4.5:1.
Does WCAG round contrast ratios?
No. The thresholds are minimums, and the W3C's guidance on success criterion 1.4.3 says a ratio is not rounded up to meet one: 4.499:1 does not meet 4.5:1. This checker decides pass or fail on the exact value, and when two decimals would display a failing ratio as the number it missed, it shows a third decimal instead.
What is the lightest gray text that passes on white?
#767676, at 4.54:1. One step lighter, #777777, measures 4.48:1 and fails AA for normal text, which surprises people because the two are indistinguishable. For AAA on white, the lightest gray is #595959 at 7.00:1.
How do I convert HEX to RGB by hand?
Split the six digits into three pairs for red, green and blue, and read each pair as a base-16 number: the first digit times 16 plus the second. In #42A4C7, 42 is 4 × 16 + 2 = 66, A4 is 10 × 16 + 4 = 164, and C7 is 12 × 16 + 7 = 199, so the color is rgb(66, 164, 199). A three-digit code doubles each digit, so #4AC means #44AACC.
What is OKLCH, and should I use it?
OKLCH describes a color by lightness, chroma (colorfulness) and hue, in a space designed so that equal steps look like equal changes. In HSL, yellow and blue at the same lightness look nothing alike; in OKLCH they do, which makes it far easier to build a palette or darken a brand color without its hue drifting. Every current major browser supports oklch() in CSS: Safari since 15.4, Chrome since 111 and Firefox since 113.
Why did my OKLCH or Display P3 color change when converted to HEX?
A hex code can only describe colors inside sRGB, the range of a standard monitor. OKLCH, Lab and color(display-p3) can describe more saturated colors that newer screens can show. When a color falls outside sRGB, this tool follows the CSS Color 4 gamut-mapping method: it keeps the lightness and hue and lowers the chroma until the color fits, which changes it far less than clipping each channel would.
How is contrast measured when a color is transparent?
On the color you actually see. A transparent text color is blended with the background behind it, the same way the browser draws it, and the contrast of that blended color is measured. A transparent background is assumed to sit on white. A 50% black on white, for example, is measured as #808080, which reaches only 3.95:1.
Is anything I enter sent to a server?
No. Parsing, conversion and the contrast calculation all run in your browser. Nothing you type leaves your device.
The Internet Omni-Tool