Skip to content
Icons and graphics

OKLCH Color Converter

Paste any CSS colour or move the lightness, chroma and hue sliders, then copy it as OKLCH, OKLab, hex, RGB or HSL, with a palette at the same hue.

Last checked

Colour

Converts as you type.

Result

As written
sRGB fallback
  • Inside sRGB
  • Inside Display P3
OKLCH
oklch(68% 0.17 255)
OKLab
oklab(68% -0.044 -0.1642)
HEX
#4699fe
RGB
rgb(70 153 254)
HSL
hsl(212.9 98.9% 63.5%)
Display P3
color(display-p3 0.3597 0.5923 0.9669)

Gamut map

Lightness × Chroma at hue 255.0°
Hue × Chroma at lightness 68.0%
Hue × Lightness at chroma 0.170

Click or drag to pick; with a map focused, arrow keys move the point (Shift for bigger steps). The black outline is the sRGB edge, the white outline the Display P3 edge. Faded areas are inside P3 but outside sRGB and are drawn with their clipped sRGB colour; blank areas are outside both.

Contrast as text

BackgroundSampleWCAG 2 ratioAPCA Lc
White2.90:1 Fails54.9
Black7.24:1 AAA-46.9

Uses the sRGB fallback with alpha ignored. APCA Lc is calculated with APCA 0.0.98G-4g (the apca-w3 constants); it is not a WCAG requirement, and WCAG 2 conformance is judged by the ratio. Negative Lc means light text on a dark background.

Palette at this hue

  1. 50#eff6ff
  2. 100#d9eaff
  3. 200#b8d7ff
  4. 300#8bbeff
  5. 400#56a0fc
  6. 500#2f83e5
  7. 600#1768c1
  8. 700#0051a0
  9. 800#003e7e
  10. 900#002d5e
  11. 950#001e43

Steps keep the hue, set lightness on a fixed ramp and lower chroma where a step would leave sRGB (marked with a dot). The Tailwind block names each step --color-brand-500, which gives you bg-brand-500 and the other utilities.

How to use it

  1. Type or paste a colour in any CSS format. The other formats update as you type; a value it cannot read is marked.
  2. Adjust lightness, chroma and hue with the sliders, or pick a point on a gamut map to see how far the colour can go before it leaves sRGB or P3. The left swatch shows the colour as your screen draws it, the right one the sRGB fallback.
  3. Copy the format you need. For a design system, name the scale and copy the CSS variables, or the @theme block for Tailwind v4, which turns each step into utilities such as bg-brand-500.

What it checks and why

OKLCH is the cylindrical form of OKLab, a colour space Björn Ottosson published in 2020 so that equal steps look like equal changes. L is perceived lightness from 0 to 100%, C is chroma (how colourful, from 0 up to about 0.37 in practice) and H is the hue angle. CSS Color Level 4 added oklch() and oklab(), and current versions of Chrome, Edge, Firefox and Safari support both.

Because lightness is perceptual, two OKLCH colours with the same L look about as light as each other, which HSL does not promise. That makes it easier to build a palette by changing one number, or to keep contrast steady across hues.

OKLCH can describe colours that a screen cannot show. The tool tests the colour against sRGB and Display P3. When it falls outside sRGB, the hex, RGB and HSL values come from lowering chroma at the same lightness and hue until the colour fits, so you can write the hex first as a fallback and the oklch() value after it.

The gamut maps are slices through OKLCH with one channel held at the current value. The black outline is where sRGB ends and the white outline where Display P3 ends. Areas inside P3 but outside sRGB are faded because a normal canvas draws in sRGB; blank areas are outside both.

The contrast table treats the colour as text on white and on black. The WCAG 2 ratio is what WCAG 2.2 success criteria 1.4.3 and 1.4.6 test: 4.5:1 for AA body text, 3:1 for large text and 7:1 for AAA. APCA Lc comes from the Accessible Perceptual Contrast Algorithm, version 0.0.98G-4g, with the constants of the official apca-w3 package. It is shown for reference only: APCA is not a WCAG requirement.

Specs and sources

Limits

  • Gamut mapping lowers chroma with a binary search and clips rounding error. CSS Color 4 describes a slightly different algorithm, so a browser's own mapping can differ by a small amount.
  • The swatch can only show what your screen can: on an sRGB display a P3 colour looks the same as its fallback.
  • The palette uses a fixed lightness ramp. It is a starting point; check text contrast on the steps you use.
  • The gamut maps are drawn at low resolution and scaled up, so the outlines are accurate to about 1 to 2 percent of each axis. P3-only areas show their clipped sRGB colour, not the real P3 colour.
  • Contrast uses the sRGB fallback and ignores alpha. APCA is still in development and its numbers can change between versions.
  • CIE Lab, CIE LCH and Rec. 2020 are not read or written yet; only sRGB, linear sRGB and Display P3 in color().

Questions

How do I convert hex to OKLCH?
Paste the hex value, for example #3b82f6, into the colour field. The OKLCH value appears in the result list with a copy button, along with OKLab, RGB, HSL and Display P3.
What do the three OKLCH numbers mean?
Lightness from 0 to 100%, chroma from 0 (grey) upwards, and hue as an angle from 0 to 360 degrees. Red sits near 30, green near 140 and blue near 260.
Can I use oklch() in CSS today?
Yes. Current Chrome, Edge, Firefox and Safari support oklch(). For very old browsers, declare a hex colour first and the oklch() value after it, so they keep the first one.
Why does my colour look the same in both swatches?
Either the colour already fits sRGB, so the fallback is identical, or your display only covers sRGB and cannot show the extra saturation of a wide gamut colour.
Is OKLCH better than HSL?
For palettes, usually. HSL lightness is not perceptual, so yellow and blue at the same HSL lightness look very different. OKLCH keeps lightness consistent across hues.
What is the maximum chroma for a colour in sRGB?
It depends on lightness and hue. Pick the lightness × chroma map: the black outline shows the highest chroma sRGB can show at each lightness for the current hue, and the white outline the same for Display P3.
Should I use the WCAG ratio or APCA?
For conformance, the WCAG 2 ratio: it is what WCAG 2.2 tests. APCA Lc is shown as extra information; it is not a WCAG requirement.