Colour converter — HEX, RGB, HSL, OKLCH, Lab, CMYK and Display P3

Paste one colour value in any notation and the converter writes it in 13 others, and tells you when the colour is too vivid for ordinary sRGB screens.

Live demo · real result from this tool
Hex, rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch(), color(display-p3 …), hsv(), cmyk() or a CSS name.
HEX#3b82f6
RGB
rgb(59, 130, 246)
RGB (CSS 4)
rgb(59 130 246)
HSL
hsl(217.2, 91.2%, 59.8%)
HSV / HSB
hsv(217.2, 76%, 96.5%)
HWB
hwb(217.2 23.1% 3.5%)
CMYK (naive)
cmyk(76%, 47%, 0%, 4%)
Lab (D50)
lab(54.62% 8.76 -65.79)
LCH (D50)
lch(54.62% 66.37 277.59)
OKLab
oklab(62.31% -0.0332 -0.1851)
OKLCH
oklch(62.31% 0.188 259.81)
Display P3
color(display-p3 0.3047 0.5035 0.9338)
Nearest CSS name
dodgerblue (≈ #1e90ff)

Colours

Processed on your device — nothing is uploaded.

How to use the colour converter

  1. Paste or type a value into Colour in any notation. Examples: #3b82f6, rgb(59 130 246), hsl(217 91% 60%), oklch(62% 0.19 260), cmyk(76%, 47%, 0%, 4%) or rebeccapurple.
  2. All other notations appear at once, with a swatch of the colour.
  3. If a yellow warning appears, your colour is outside sRGB; read the FAQ below on what that means.
  4. Copy the line you need.

What it does and when to use it

Colour values travel between tools that speak different languages. A brand guide gives CMYK, a design file gives HSB, a stylesheet wants HEX, and a modern design system may be written in OKLCH. This converter reads all of these and returns the colour as HEX, RGB in two CSS styles, HSL, HSV/HSB, HWB, CMYK, CIE Lab and LCH, OKLab and OKLCH, Display P3, and the nearest CSS colour name.

Use it when moving colours between apps, when updating an old stylesheet to OKLCH, or when you need to check what a Lab value from a colour-measuring device looks like. If you would rather choose a colour visually, start with the colour picker. Once you have the codes, test text on it with the contrast checker, or see how it looks to people with colour-vision deficiencies in the colour blindness simulator.

How it works

  • The input is parsed using CSS Color Level 4 rules, plus hsv(), hsb() and cmyk(), which are not CSS but are common in design tools.
  • The colour is held as unclamped sRGB values, so very saturated colours keep their true values while being converted.
  • Lab and LCH use the D50 white point, as CSS does. OKLab and OKLCH use Ottosson’s matrices.
  • For colours outside sRGB, the screen-only notations show a gamut-mapped colour: the converter lowers chroma in OKLCH, keeping lightness and hue, until the colour fits. This is the method CSS Color 4 describes.
  • CMYK uses the naive formula: K = 1 − max(R, G, B), then C = (1 − R − K) ÷ (1 − K), and the same for M and Y.

Worked examples

All values below are the converter’s output.

Pure red. hsl(0 100% 50%) becomes #ff0000, cmyk(0%, 100%, 100%, 0%) and oklch(62.8% 0.2577 29.23). Its Display P3 value is color(display-p3 0.9175 0.2003 0.1386), which shows that sRGB red is not the reddest red a P3 screen can show.

A green too vivid for sRGB. oklch(70% 0.4 150) triggers the gamut warning. The nearest sRGB colour is #00c248, rgb(0, 194, 72), while the OKLCH line keeps the original oklch(70% 0.4 150).

Limits and tips

  • Rounding. Converting through HSL with whole numbers, or through CMYK, can move a colour by one step in a channel. Keep the original HEX as your reference.
  • Alpha is kept when you type it (#3b82f680, rgb(59 130 246 / 50%)).
  • Spot colours such as Pantone are not included; they are licensed ink systems, not formulas.
  • The work happens in your browser. Nothing you paste is uploaded.

Frequently asked questions

How do I convert HEX to RGB?
Paste the HEX code, for example
What is the difference between HSL and HSV?
Both use hue and saturation, but the third number differs. In HSL, 100% lightness is always white and 50% is the pure colour. In HSV (also called HSB), 100% value is the brightest version of the colour. Design apps often use HSV, while CSS uses HSL.
Why does it say my colour is outside the sRGB gamut?
Notations such as oklch(), lab() and color(display-p3 …) can describe colours more saturated than a standard sRGB screen can show. The converter keeps the original in Lab, LCH, OKLab, OKLCH and Display P3, and gives the nearest displayable colour in HEX, RGB, HSL, HSV, HWB and CMYK.
Is the CMYK value ready for printing?
Treat it as a starting point. It uses the simple device formula, while real print colour depends on the paper, ink and the printer's ICC profile. Ask your printer which profile to use.
Which notation should I use in CSS?
HEX and rgb() work everywhere. oklch() is useful for building palettes, because changing its lightness keeps the hue looking steady. Modern browsers support all of them.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close