Type any colour into the converter below — a CSS keyword, HEX, RGB, HSL, HWB, CMYK or NCol — and it returns every other format at once, including oklch(). As a rule of thumb in 2026: use HEX for handoff, OKLCH for design tokens and anything you generate tints and shades from, and treat the CMYK values as a rough screen preview rather than print‑ready numbers.
Key points
- Converts between CSS colour names, HEX, RGB, HSL, HWB, OKLCH, CMYK and NCol.
- HEX and RGB are for handoff; OKLCH is what you build a palette in.
- OKLCH lightness is perceptual, so equal
Lvalues genuinely look equally light. hwb()is space‑separated only — commas inside it are a parse error.- CMYK here is an approximation; real print work needs an ICC profile.
That isn’t a colour value we recognise. Try a name, a HEX code, or an rgb() value.
| Name | — |
| hex | — |
| rgb | — |
| hsl | — |
| hwb | — |
| oklch | — |
| cmyk | — |
| ncol | — |
HEX, RGB, HSL, HWB and OKLCH values are ready to paste straight into CSS. CMYK is an approximation for screen — see the note on print below.
How to use it
- Type or paste a value into the field. Everything updates as you type — there is no submit button.
- Accepted input includes CSS colour keywords (
rebeccapurple), HEX (#3366ffor#36f),rgb(),hsl(),hwb(),cmyk()and NCol. - Use the colour well next to the field if you would rather pick a colour visually.
- Alpha is preserved. Enter
rgba(255, 0, 0, 0.5)and the RGB, HSL, HWB and OKLCH rows all come back with the alpha component. - If the value cannot be parsed, the table hides and an error message appears — usually a stray unit or a missing
#.
Which colour format should I use in CSS in 2026?
Short version: HEX to hand a colour to someone, OKLCH to work with it.
- HEX — fine as a value, useless as a thing you edit. You cannot reason about a hex string, but everyone can paste one.
- RGB — use it when something else hands you channels: a canvas, an image picker, an API response.
- HSL — readable, and still fine for a one‑off value. Do not build a design system on it, for the reason in the table below.
- OKLCH — the default for design tokens, palettes and any programmatic lightness or chroma change. Interoperable across browsers since May 2023 and Baseline widely available since November 2025, so it needs no caveat now.
color-mix()— reach for it before writing a tint generator by hand, and mix in a perceptual space:color-mix(in oklab, var(--brand) 80%, white)rather thanin srgb, which goes muddy in the middle.color(display-p3 …)— only for brand colours sRGB genuinely cannot reach, and always with an sRGB value first so the cascade has something to fall back to.- Relative colour syntax —
rgb(from var(--brand) r g b / 50%)is genuinely useful, but it is the one feature here still at Baseline newly available, so treat it as an enhancement.
Why HSL breaks palettes and OKLCH does not
In HSL, L is lightness relative to other colours of the same hue, not lightness as your eye perceives it. So six colours that all claim to be 50% lightness are nothing of the sort:
| Colour | HSL | Actual perceived lightness (OKLCH L) | Contrast on white |
|---|---|---|---|
| Yellow | hsl(60 100% 50%) | 96.8% | 1.07:1 |
| Cyan | hsl(180 100% 50%) | 90.5% | 1.25:1 |
| Green | hsl(120 100% 50%) | 86.6% | 1.37:1 |
| Magenta | hsl(300 100% 50%) | 70.2% | 3.14:1 |
| Red | hsl(0 100% 50%) | 62.8% | 4.00:1 |
| Blue | hsl(240 100% 50%) | 45.2% | 8.59:1 |
50% in HSL spans a 51‑point range of real perceived lightness. Yellow is effectively invisible on white; blue passes AAA.That is why a palette built by stepping HSL lightness produces shades that look uneven, and why swapping the hue of a token can silently destroy its contrast. Step OKLCH L instead and the ramp looks as even as it measures.
Wide‑gamut colour, safely
Most current phones and laptops have Display‑P3 screens, which reach saturated reds and greens sRGB cannot. Declare the sRGB value first and override it only where the display can show the difference:
:root { --brand: #51bc56; } /* sRGB fallback, always first */
@media (color-gamut: p3) {
:root { --brand: color(display-p3 0.32 0.73 0.34); }
}
Both the color() function and the color-gamut media feature are Baseline widely available, so this pattern is safe to ship. Without a fallback the browser will gamut‑map your colour to something you did not choose.
What each format actually is
RGB — an additive model: red, green and blue light combined in different amounts. It is how screens physically work, which is why it underlies every other screen format here.
HEX — the same RGB channels written as three pairs of hexadecimal digits. #ff0000 is rgb(255 0 0). A fourth pair adds alpha.
HSL — hue, saturation and lightness. Far easier to read than HEX, and the reason it stayed popular; just be aware its lightness is not perceptual.
HWB — hue, whiteness and blackness. A cylindrical model like HSL, but expressed as “this hue, with this much white and black mixed in”, which matches how people mix paint. It arrived with CSS Color 4 and so has always been space‑separated: hwb(194 0% 0% / 0.5). Commas inside hwb() are a parse error, which is why this converter emits the space‑separated form.
OKLCH — lightness, chroma and hue in the Oklab perceptual space. The headline property is that its L corresponds to lightness as the eye sees it, so two colours with the same L really do look equally light regardless of hue.
CMYK — a subtractive model for print: cyan, magenta, yellow and key (black) ink on paper. CSS does define a device-cmyk() function, but no browser implements it, and CMYK numbers only mean something alongside a specific printer, ink and paper profile. Treat the values here as a preview and send your printer an ICC profile, not these numbers.
NCol — “natural colours”, a notation from W3Schools that names a hue with a letter and a percentage distance from it. It is a teaching device rather than a web standard: it appears in no CSS specification and no browser parses it.
Related tools
- Colour scheme generator — build a full palette around the colour you have just converted.
- CSS gradient generator — turn two of these colours into a gradient with the CSS to go with it.
- Random colour generator — for when you need a starting point rather than a specific value.
- All design tools — the rest of the set.
Once a palette is in place, the thing worth checking is that it still works where it matters — on small controls, in both states of a toggle button, and against your body text. A free audit of your site will report the contrast failures a palette introduces once it is actually in use.