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
#8D95AA - RGB
rgb(141 149 170) - HSL
hsl(223 15% 61%) - OKLCH
oklch(67.0% 0.032 269) - CMYK
17%, 12%, 0%, 33%
White text 2.99:1 (fails AA) · black text 7.01:1 (AA)
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.