DevToolCase
Sign in Sign in

Convert colors: HEX, RGB, HSL, OKLCH

Convert a CSS color between HEX, RGB, HSL, HWB, OKLCH and named colors, with a color picker and its contrast on white and black.

Share this result

Encrypted in your browser. The key stays in the link, after “#”: only the people you give it to can read it, not even DevToolCase.

The link works for

Sign in for longer links or links without expiry, and to find them in your account.

Runs entirely in your browser: nothing you type is sent or stored.

The CSS color formats

Type a color in any notation CSS understands, or pick it: it is written back in every format, ready to copy into a style sheet.

NotationExampleWhat it describes
HEX#3b82f6red, green and blue from 00 to ff, the most common in design tools
RGBrgb(59, 130, 246)the same channels from 0 to 255
HSLhsl(217, 91%, 60%)hue (an angle on the color wheel), saturation, lightness
HWBhwb(217 23% 4%)hue, then how much white and black are mixed in
OKLCHoklch(62.3% 0.188 259.8)perceived lightness, chroma (colorfulness) and hue
Nametomatoone of the 148 named colors of CSS

Both syntaxes are read: the classic one with commas, rgba(59, 130, 246, 0.5), and the modern one with spaces and a slash before the alpha, rgb(59 130 246 / 50%). Hues may be given in deg, rad, grad or turn.

Why OKLCH?

In HSL, a yellow and a blue with the same “lightness” of 50% do not look equally light at all. OKLCH is built on how the eye sees: two colors with the same L look as light as each other, so a palette made by changing only the hue or the chroma keeps an even contrast. It is supported by every current browser.

OKLCH can also describe colors that most screens cannot show (wide-gamut P3 colors). Such a color is flagged here and converted with its channels clipped to the sRGB range of the other formats.

Transparency

The alpha channel goes from 0 (transparent) to 1 (opaque). In hexadecimal it is a fourth pair of digits: #3b82f680 is 50% opaque, since 80 is 128 out of 255. The short form #rgba works too. The swatch shows a checkerboard through a translucent color.

  • ff = 100%, cc = 80%, 99 = 60%, 80 = 50%, 66 = 40%, 33 = 20%, 00 = 0%.
  • A named color is given only when it matches exactly, and only for opaque colors (plus transparent).

Readable on white, on black

Under the formats, the WCAG contrast ratio of the color as text on a white and on a black background tells at once whether it suits a light or a dark theme. To test it against your own background, use the contrast checker.

Add this browser’s favorites to your account?

This browser has 0 favorites that your account does not have:

Either way, this browser keeps its favorites: you find them again after signing out.