Skip to content
Aback UI

Free toolRuns in your browser

Colour converter: HEX, RGB, HSL, OKLCH

Paste any CSS colour and copy it back as HEX, rgb(), hsl(), or oklch(), with alpha kept and modern CSS syntax ready to use.

Paste HEX (3, 4, 6, or 8 digits), rgb(), hsl(), or oklch(), with or without alpha.

  • HEX#009bf9
  • RGBrgb(0 155 249)
  • HSLhsl(202.7 100% 48.8%)
  • OKLCHoklch(66.99% 0.1748 246.65)
  • CSS variable--brand: oklch(66.99% 0.1748 246.65);
  • Tailwind classbg-[#009bf9]
Lightness
67.0%
Chroma
0.1748
Hue
246.6°
Contrast on white / #0a0a0a
2.97:1 / 6.65:1

The four formats, briefly

  • HEX (#009bf9) is the red, green, and blue channels in base 16. It is compact and universal, and an optional fourth pair adds alpha.
  • RGB (rgb(0 155 249)) is the same three channels in decimal. Modern CSS separates them with spaces and writes alpha after a slash.
  • HSL (hsl(203 100% 49%)) describes hue, saturation, and lightness. It is easy to reason about, but its lightness does not match what you see.
  • OKLCH (oklch(65% 0.18 240)) describes perceptual lightness, chroma, and hue. It is the format Tailwind CSS v4 uses for its default palette.

Why design systems are moving to OKLCH

In OKLCH, changing only the lightness gives you a lighter or darker version of the same colour that still looks like the same hue, and two colours with the same lightness look about equally bright. That makes it a better space for generating shade scales and for predicting contrast than HSL. The trade-off is that OKLCH can describe colours a typical sRGB screen cannot show, so tools have to map them back into gamut. OKLCH colours in CSS for design systems covers this in depth.

How this converter works

Everything runs in your browser; nothing is sent anywhere. The converter parses HEX in all four lengths and the rgb(), hsl(), and oklch() functions in both modern space-separated and legacy comma syntax. OKLCH values use the OKLab definition by Björn Ottosson, and out-of-gamut colours are reduced in chroma at constant lightness and hue. The values are rounded for display: OKLCH to two decimals of lightness and four of chroma, which is far below what the eye can distinguish.

Next steps

Turn a converted colour into a full 50 to 950 scale with the Tailwind colour scale generator, check it against its background with the contrast checker, or see how Aback UI names its colours by role on the colours page.

Frequently asked questions

How do I convert HEX to OKLCH?

Paste the HEX value into the converter and copy the OKLCH row. Under the hood the HEX is decoded to sRGB, linearized, converted to OKLab with Björn Ottosson's matrices, and then expressed as lightness, chroma, and hue.

Why do some OKLCH colours change when converted to HEX?

OKLCH can describe colours that sRGB screens and HEX cannot show. When that happens the converter keeps the lightness and hue and lowers the chroma until the colour fits, and it tells you it did so.

Which browsers support oklch() in CSS?

All current versions of Chrome, Edge, Firefox, and Safari support oklch() in CSS. If you need to support much older browsers, keep a HEX or rgb() fallback declared before the oklch() value.

Is HSL lightness the same as OKLCH lightness?

No. HSL lightness is a simple average of the channels and does not match how bright colours look: yellow and blue at 50% HSL lightness look very different. OKLCH lightness is perceptual, so equal values look about equally bright across hues.