Huebook

Color code converter

Paste a color in any format, from HEX and rgb() to hsl(), oklch() or a CSS name. Every format updates as you type.

Paste or type a color in any CSS format. Try: , , , , ,

  • HEX#836E59
  • RGBrgb(131 110 89)
  • HSLhsl(30 19% 43%)
  • OKLCHoklch(55.3% 0.041 67)
  • CMYK0%, 16%, 32%, 49%

White text 4.84:1 (AA) · black text 4.34:1 (AA large only)

The formats in short

HEX writes a color as three pairs of hexadecimal digits for red, green and blue, from 00 to FF; an optional fourth pair is the opacity. RGB gives the same channels as numbers from 0 to 255. HSL describes hue (an angle on the color wheel), saturation and lightness, which makes lighter and darker versions easy to write.

OKLCH is the newest CSS format: lightness, chroma and hue in a space built to match how people see color, so two colors with the same L look equally light. CMYK is for print; the values here are a plain conversion without a printer profile, so check them against a proof.

Converting by hand

To turn HEX into RGB, read each pair as a base-16 number: 3D is 3 × 16 + 13 = 61. For HSL, scale R, G and B to 0–1; lightness is the average of the largest and smallest channel, and saturation and hue follow from how far apart the channels are.

More tools: gradient generator, shadow generator, all CSS named colors.

Questions

Which color format should I use in CSS?

All modern browsers read HEX, rgb(), hsl() and oklch(). HEX is the most common in design hand-offs; oklch() is the best choice for building palettes, because equal lightness values look equally light.

What does an 8-digit hex code mean?

The last two digits are the opacity, from 00 (transparent) to FF (opaque). #0af8 is the short form of #00aaff88, about 53% opaque.

Why do RGB and CMYK not match exactly?

Screens mix light and printers mix ink, and printers cannot reproduce every screen color. Exact print colors need the printer’s color profile.

Color code converter: HEX, RGB, HSL, OKLCH, CMYK | Huebook