toolqik

108 · Encode & Convert

Color Converter

HEX, RGB, HSL, OKLCH and CMYK, with contrast checks and shades.

Runs in your browser
AaAa

Contrast (WCAG 2)

Click any value above to copy it. 4.5:1 is the minimum for body text (AA).

Tints and shades

Mixed with white and black in 20% steps. Click a swatch to use it.

About this tool

Design tools hand you HEX, CSS wants rgb() or oklch(), and print asks for CMYK. This color converter takes any CSS colour, including names like tomato, and shows it in every common format at once, with a click-to-copy value for each. It also checks text contrast against white and black and builds a tints-and-shades scale, all in your browser.

How to use it

  1. Type or paste a colour in any format: #ff5733, ff5733, rgb(255 87 51), hsl(11 100% 60%), oklch(0.68 0.21 33.7), cmyk(0, 66, 80, 0) or a CSS name.
  2. Or click the swatch button to open your system colour picker. In Chrome and Edge, the eye button picks a colour from anywhere on your screen.
  3. Click any converted value to copy it, and click a tint or shade to convert that one instead.

Colour formats compared

FormatExampleBest for
HEX#ff5733, #ff573380Design handoff and short CSS values. Eight digits add alpha.
RGBrgb(255, 87, 51)Code that works with channel values, such as canvas and image processing.
HSLhsl(10.6, 100%, 60%)Quick tweaks by hand: change lightness or saturation and keep the hue.
HWBhwb(10.6 20% 0%)Mixing a hue with white and black, like a paint picker.
OKLCHoklch(0.6804 0.21 33.69)Design systems and palettes: equal steps in lightness look equal to the eye.
CMYKcmyk(0%, 66%, 80%, 0%)A starting point for print. Not a CSS colour.

Why OKLCH?

HSL is simple but not perceptual: hsl(60 100% 50%) (yellow) looks far lighter than hsl(240 100% 50%) (blue), even though both say 50% lightness. In OKLCH, the L value tracks how light a colour actually looks, C is how colourful it is, and H is the hue angle. That makes it the best choice for generating palettes and hover states, and for keeping contrast predictable when you change hue. Every current browser supports it. OKLCH can also describe colours outside the sRGB range of most screens; this converter clips those to the nearest displayable colour and tells you when it does.

Contrast and accessibility

The contrast ratio compares the relative luminance of two colours, from 1:1 (identical) to 21:1 (black on white). The WCAG 2 thresholds are:

  • AA: at least 4.5:1 for normal text and 3:1 for large text (about 24px, or 18.66px bold) and for icons and input borders.
  • AAA: at least 7:1 for normal text and 4.5:1 for large text.

For example, #767676 is the lightest grey that passes AA on white, at 4.54:1. If your colour is translucent, the converter blends it over white or black before measuring, as a browser would draw it.

A note on CMYK

Screens mix light (RGB) and printers mix ink (CMYK), and the exact conversion depends on the paper, ink and colour profile. The CMYK values here use the standard simple formula, which is fine for a rough match. For brand colours in print, ask your printer for values that match their profile, or use the Pantone or CMYK values from your brand guide.

Convert colours in code

// HEX -> RGB
const hex = '#ff5733';
const n = parseInt(hex.slice(1), 16);
const rgb = [(n >> 16) & 255, (n >> 8) & 255, n & 255];   // [255, 87, 51]

// RGB -> HEX
const toHex = (r, g, b) =>
  '#' + [r, g, b].map((v) => v.toString(16).padStart(2, '0')).join('');
toHex(255, 87, 51);                                         // '#ff5733'

FAQ

How do I convert HEX to RGB?

Split the six hex digits into three pairs and convert each from base 16: #ff5733 is ff=255, 57=87, 33=51, so rgb(255, 87, 51). Paste any HEX code above to convert it instantly.

What is the difference between RGB and HEX?

Nothing but notation. Both describe the same red, green and blue channels from 0 to 255; HEX writes each channel as two hexadecimal digits.

What is OKLCH in CSS?

A colour format based on how people perceive lightness, chroma (colourfulness) and hue. It makes palettes and hover states more consistent than HSL and is supported in all modern browsers.

How do I write a colour with transparency?

Use eight-digit HEX (#ff573380), rgba(255, 87, 51, 0.5), or the modern slash syntax rgb(255 87 51 / 50%). Every format here supports alpha.

What contrast ratio do I need for text?

WCAG AA requires 4.5:1 for normal text and 3:1 for large text. AAA requires 7:1 and 4.5:1. The contrast panel shows the ratio against white and black.

Is the CMYK conversion exact?

No conversion from screen colours to ink is exact without a colour profile. Use these values as a starting point and confirm with your printer.

esc
↑↓ navigate↵ open