Menu
Developer · Design

Color Tools

Pick colors, convert between HEX, RGB, and HSL, build palettes, and generate CSS gradients. An essential toolkit for designers.

Color Tools

Random Palette

Press generate for a new 5-color palette. Click any swatch to copy its HEX.

Colour tools — color tools in American spelling — convert between the notations browsers accept and check whether a pairing is actually readable. The second job matters more: contrast failures are the single most common accessibility problem on the web, and they are entirely preventable at design time.

The notations

FormatExampleGood for
HEX#3B82F6Compact, universally supported
RGBrgb(59 130 246)Programmatic manipulation
HSLhsl(217 91% 60%)Building palettes by adjusting one value
HEX with alpha#3B82F680Transparency in a compact form
OKLCHoklch(0.62 0.19 259)Perceptually even lightness steps

HSL is the practical choice for building a palette by hand: hold hue and saturation constant, vary lightness, and you have a coherent scale. The catch is that HSL lightness is not perceptual — hsl(60 100% 50%) (yellow) looks far brighter than hsl(240 100% 50%) (blue) at the same stated lightness. OKLCH fixes this, which is why design systems are increasingly built on it.

Contrast ratios

Contrast is the ratio between the relative luminance of two colours, from 1:1 (identical) to 21:1 (black on white).

ContentWCAG AAWCAG AAA
Body text4.5:17:1
Large text (18pt+, or 14pt bold)3:14.5:1
UI components, focus indicators, icons3:1—

The failures that recur most: light grey placeholder text, white text on mid-tone brand colours, and disabled states so faint they cannot be read at all. Note that contrast is calculated from luminance, not from how different two colours look — two colours of similar lightness but opposite hue can look distinct and still fail badly.

Do not rely on colour alone

Around 8% of men and 0.5% of women have some form of colour vision deficiency, most commonly difficulty distinguishing red from green. A form marking errors only in red, a chart distinguishing series only by hue, or a status dot with no label all fail for those users. Add an icon, a label, a pattern or a text cue alongside the colour — this costs almost nothing and is one of the highest-value accessibility habits available.

Building a usable palette

  1. Choose one primary colour.
  2. Generate a scale by varying lightness in even perceptual steps — typically nine or ten shades.
  3. Check which shades pass 4.5:1 against your background, and use only those for text.
  4. Add semantic colours for success, warning, error and information, and check each against the surfaces it appears on.
  5. Define neutrals separately; slightly tinting greys toward your primary hue makes an interface feel more coherent.

Dark mode is not an inversion

Inverting a light palette produces harsh, over-saturated results. Pure white text on pure black causes halation and eye strain for many readers. Prefer a very dark grey background with a slightly off-white text colour, desaturate accent colours a little, and re-check every contrast pairing — a colour that passes on white frequently fails on a dark surface.

FAQ

Frequently Asked Questions

What contrast ratio do I need?
4.5:1 for body text and 3:1 for large text or user interface components under WCAG AA. AAA requires 7:1 for body text. AA is the level most legislation and procurement standards reference.
Which colour format should I use?
HEX for simple values, HSL when building a palette by adjusting lightness, and OKLCH when you want perceptually even steps. Browser support for OKLCH is now broad enough for production use with a fallback.
Why does my palette look uneven?
HSL lightness is not perceptual — yellow at 50% lightness appears far brighter than blue at 50%. Use OKLCH, or adjust lightness values by eye per hue rather than using a fixed mathematical step.
Is it enough to check contrast?
No. Colour must never be the only way information is conveyed, because around 8% of men have some colour vision deficiency. Pair colour with an icon, label or pattern.
Can I just invert my colours for dark mode?
Inversion produces harsh, over-saturated results, and pure white on pure black causes eye strain. Use a very dark grey background, slightly off-white text, desaturated accents, and re-test every contrast pairing.
Does transparency affect contrast?
Yes. A semi-transparent colour blends with whatever is behind it, so the effective contrast depends on the backdrop. Calculate against the actual composited colour, not the declared one.
Keep exploring

Related Developer Tools

Browse all Developer tools →