DevKit

Color Converter

Convert between HEX, RGB and HSL, then check the contrast ratios that matter for accessibility.

Free No sign-up Runs in your browser
Color
Shadesclick to copy
WCAG contrast

AA needs 4.5:1 for body text and 3:1 for large text (18px+ or 14px bold). AAA needs 7:1.

Three ways to describe one color

HEX (#3D5AF1) is how colors are written in CSS and design tools: three pairs of hex digits for red, green and blue. Compact, but not human-readable — you cannot tell by looking that it is a blue.

RGB (rgb(61, 90, 241)) is the same data in decimal, matching how screens mix light. Add an alpha channel and it becomes rgba().

HSL (hsl(230, 86%, 59%)) describes a color as hue, saturation and lightness. This is the model designers actually think in: to make a hover state, lower the lightness; to mute a badge, lower the saturation. Generating a consistent palette is trivial in HSL and painful in HEX.

Perceptual problems with HSL

HSL is not perceptually uniform. Two colors with the same lightness value can look very different in brightness — pure yellow at 50% lightness looks far brighter than blue at 50%. Modern CSS adds oklch() and lab(), which are perceptually uniform, so a lightness step produces a visually even step. If you are building a design system today, OKLCH is worth adopting; HSL remains the easiest mental model for quick tweaks.

Contrast is a hard requirement, not a preference

WCAG 2.2 requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text (18pt, or 14pt bold) at level AA. Level AAA asks for 7:1. The ratio is computed from relative luminance, not from raw RGB values — which is why "just use a darker grey" often fails silently. The checker above reports both directions, because text on a color and the same color as text are different questions.

Transparency and compositing

An alpha channel is not a lighter color: rgba(0,0,0,0.5) over white looks grey, but over blue it looks dark blue. Contrast must be measured against the composited result, so a 50% black label on a photo can pass on one area and fail on another. Test with the real background, not an approximation.

Color and accessibility beyond contrast

Roughly 8% of men have some form of color vision deficiency. Never encode meaning with hue alone — pair it with an icon, a label or a pattern. Red/green status indicators are the classic failure.

Frequently asked questions

What contrast ratio do I need?
AA: 4.5:1 for body text, 3:1 for text at 18px+ or 14px bold. AAA: 7:1 and 4.5:1 respectively. UI components and focus rings need 3:1 against adjacent colors.
Why do HSL and HEX give slightly different results?
HSL values are rounded to whole degrees and percentages, so converting back can be off by one unit per channel. The HEX and RGB values are the source of truth.
Should I use OKLCH instead?
For design systems, yes — it is perceptually uniform, so equal lightness steps look equal. Support is good in modern browsers; keep an sRGB fallback if you must support older ones.
How do I make a darker shade properly?
Lower lightness in HSL, or move along the L axis in OKLCH. Simply multiplying RGB values shifts hue and saturation, which is why naive darkening looks muddy.

Related tools