Colour converter

Paste a colour in any CSS format to get it as HEX, RGB, HSL, HWB, OKLCH and OKLAB, with its contrast against black and white and a scale of lighter and darker shades.

  • Colour
  • Runs in your browser. Nothing is uploaded

Contrast

Check against any background →

Lighter and darker

Steps in OKLCH lightness, keeping the same hue. Click one to use it.

Type a colour

One colour, every format

FormatExampleGood for
HEX#3b82f6Design tools, compact CSS
RGBrgb(59 130 246)Mixing channels in code
HSLhsl(217 91% 60%)Quick hand tweaks of hue and saturation
HWBhwb(217 23% 4%)Tints and shades: add white or black
OKLCHoklch(62.3% 0.188 259.8)Palettes, design tokens, consistent lightness
OKLABoklab(62.3% -0.033 -0.185)Smooth gradients and colour mixing

Modern CSS uses spaces between values and a slash before alpha: rgb(59 130 246 / 50%). The tool also gives the older comma form for codebases that need it.

Mistakes it fixes

  • Look-alike letters in hex, like O for 0 or l for 1.
  • Wrong number of hex digits; 5 or 7 usually means one was lost or doubled when copying.
  • A missing #, or a missing closing bracket.
  • Values out of range, like rgb(300 0 0) or 120% lightness, which are clamped and flagged.
  • Commas mixed with a slash for alpha, which browsers reject.
  • Misspelled colour names, with the closest real one suggested.
  • Colours outside sRGB, from wide-gamut OKLCH values, which are mapped to the nearest colour most screens can show.

Building a scale with OKLCH

The lightness scale under the converter keeps the same hue and chroma and steps the OKLCH lightness evenly, the way palettes like Tailwind’s are built. Click a step to load it. Because OKLCH lightness matches what we see, a step that passes contrast in one hue will usually pass in another at the same lightness.

:root {
  --brand-300: oklch(80% 0.1 260);
  --brand-500: oklch(62% 0.19 260);
  --brand-700: oklch(45% 0.17 260);
}

Contrast at a glance

Each colour shows its WCAG contrast ratio against white and black, so you can see straight away whether it works for text. For a full check against your own background, with AA and AAA results and the nearest passing colour, open it in the contrast checker.

Questions people ask

How do I convert HEX to RGB?
Split the six hex digits into three pairs and convert each from base 16 to base 10. #3b82f6 is 3b = 59, 82 = 130, f6 = 246, so rgb(59 130 246). A 3-digit hex like #f80 doubles each digit: #ff8800.
What is OKLCH and why use it?
OKLCH describes a colour by lightness, chroma (how colourful it is) and hue, in a way that matches how people see. Unlike HSL, two colours with the same OKLCH lightness actually look equally light, so it’s much better for building palettes and accessible colour scales. All modern browsers support oklch() in CSS.
Why does HSL lightness look different for different colours?
HSL is a simple reshuffle of RGB and ignores how sensitive our eyes are to each colour. hsl(60 100% 50%) (yellow) looks far brighter than hsl(240 100% 50%) (blue), even though both say 50% lightness. OKLCH fixes this.
How do I add transparency to a hex colour?
Add two more hex digits for alpha: #3b82f680 is about 50% opaque (80 hex = 128 of 255). In functional syntax, use a slash: rgb(59 130 246 / 50%). The old rgba() and hsla() forms still work too.
Can I paste colours from code?
Yes. Paste any hex, rgb(), rgba(), hsl(), hwb(), oklch(), oklab() or CSS colour name. Hex without a #, a missing bracket, or values out of range are marked and fixed for you.
↑↓ move↵ openesc close