# 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.

- Page: https://codethatmoves.com/tools/graphics/oklch-converter/
- Site: Code That Moves
- Category: Icons and graphics
- Free, runs in the browser, nothing is uploaded
- Last checked: 2026-11-03

## What it does

- Reads hex, the 148 CSS colour names, rgb(), hsl(), oklch(), oklab() and color(srgb | srgb-linear | display-p3), in modern or comma syntax, with alpha
- Writes the colour as color(display-p3 ...) too, so a wide gamut value can be used as is
- Lightness, chroma, hue and alpha sliders with live gradient tracks
- Three gamut maps (lightness × chroma, hue × chroma, hue × lightness) with the sRGB and Display P3 edges outlined; click, drag or use the arrow keys to pick
- Shows whether the colour fits sRGB and Display P3, and maps it into sRGB by lowering chroma for the hex fallback
- Contrast against white and black: the WCAG 2 ratio with AA and AAA levels, plus APCA Lc (0.0.98G-4g) for reference
- An 11-step lightness scale at the same hue, copied as CSS custom properties or as a Tailwind CSS v4 @theme block
- Copy each format or a share link to the colour

## 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

- [W3C: CSS Color Module Level 4, OKLab and OKLCH](https://www.w3.org/TR/css-color-4/#ok-lab)
- [Björn Ottosson: A perceptual color space for image processing](https://bottosson.github.io/posts/oklab/)
- [MDN: oklch()](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklch)
- [W3C: WCAG 2.2, Contrast (Minimum)](https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html)
- [Myndex: apca-w3 source (APCA 0.0.98G-4g constants)](https://github.com/Myndex/apca-w3/blob/master/src/apca-w3.js)

## 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.
