Colour Name to Hex / RGBA Converter

Convert CSS named colours, Tailwind classes, and hex to every colour space

Ad placeholder (leaderboard)

The Colour Name to Hex / RGBA Converter resolves any CSS named colour, hex code, or rgb() value to a canonical hex and then expresses it across six colour spaces: hex, RGB, HSL, HSV, CIELAB, and OKLCH. Named colours like rebeccapurple are convenient in code but opaque when you need their exact channel values for a contrast check or to generate a theme. This tool gives you every representation at once, computed locally with the standard formulas.

How it works

  1. Resolve to RGB. A named colour is looked up in the bundled 148-entry CSS colour table; a hex code is parsed (3, 4, 6, or 8 digit); an rgb()/rgba() value is read directly. The result is an 8-bit RGB triple plus alpha.
  2. HSL and HSV. Both are derived from RGB using the standard hexcone formulas — they share the same hue angle but differ in how they express brightness.
  3. CIELAB. RGB is gamma-expanded to linear sRGB, multiplied by the sRGB-to-XYZ matrix under the D65 white point, then transformed to L*a*b* with the CIE cube-root function.
  4. OKLCH. Linear sRGB is converted to OKLab via Bjorn Ottosson’s published matrices and cube-root step, then a/b are turned into chroma and hue to give OKLCH — the perceptually uniform space modern palette tools rely on.

Tips and notes

  • OKLCH lightness is perceptual, so two colours with the same L look equally bright; that is why it is preferred for building accessible light/dark palettes.
  • For contrast ratios you only need the sRGB channels — copy the RGB or hex value into a WCAG contrast tool.
  • An 8-digit hex (#3b82f6cc) carries an alpha channel; the converter shows the alpha separately so you can keep or drop it.
Ad placeholder (rectangle)