OKLCH Converter (HEX, RGB, HSL to OKLCH & Back)

Convert HEX, RGB, HSL and RGBA to OKLCH, or OKLCH to HEX, RGB and HSL, with sRGB and Display P3 gamut checks.

Original
HEX (sRGB)

OKLCH Converter: HEX, RGB and HSL to OKLCH and Back

This OKLCH converter turns any CSS color into an oklch() value and converts OKLCH back to HEX, RGB, HSL, HWB, OKLab and Display P3. Type or pick a color, read the result, and press Copy. It also shows whether the color fits in sRGB, Display P3 and Rec.2020, and gives a CSS fallback for older browsers. Everything runs in your browser, nothing is uploaded.

How to Convert HEX, RGB or HSL to OKLCH

  1. Stay on the To OKLCH tab and type a color such as #3b82f6, rgb(59 130 246) or hsl(217 91% 60%), or use the color picker.
  2. Copy the OKLCH row, or the Tailwind v4 and CSS variable rows if you are building a theme.
  3. To go the other way, open From OKLCH, set lightness, chroma and hue with the sliders (or paste an oklch() value in the first tab) and copy the HEX, RGB or HSL row.
  4. To migrate a whole stylesheet, open Bulk CSS, paste your CSS and copy the converted result.

HEX to OKLCH Conversion Table

ColorHEXOKLCH
Red#ff0000oklch(62.8% 0.2577 29.23)
Green#008000oklch(51.98% 0.1769 142.5)
Blue#0000ffoklch(45.2% 0.3132 264.05)
Tailwind v3 blue-500#3b82f6oklch(62.31% 0.188 259.81)
Tailwind v3 red-500#ef4444oklch(63.68% 0.2078 25.33)
Tailwind v3 green-500#22c55eoklch(72.27% 0.192 149.58)
Tailwind v3 amber-500#f59e0boklch(76.86% 0.1647 70.08)
Tailwind v3 violet-500#8b5cf6oklch(60.56% 0.2189 292.72)
Gray#808080oklch(59.99% 0 0)
Black#000000oklch(0% 0 0)
White#ffffffoklch(100% 0 0)

What Is OKLCH?

OKLCH describes a color with three numbers. L is perceived lightness (0% black to 100% white), C is chroma, how colorful it is (0 is gray, real colors stay below about 0.4), and H is the hue angle from 0 to 360 degrees. An optional alpha goes after a slash: oklch(62.8% 0.2577 29.23 / 50%). Because equal steps in L look like equal steps in brightness, you can build color scales by changing one number, which HSL cannot do reliably.

LCH vs OKLCH

LCH is the polar form of CIE Lab (D50). OKLCH is the polar form of Oklab, published by Björn Ottosson in 2020 to fix Lab's weak spots: blues drifting toward purple as lightness changes, and uneven perceived lightness. Both are part of CSS Color 4, but OKLCH is the better choice for palettes and gradients.

HEX vs OKLCH: Gamut Mapping and Fallbacks

HEX, rgb() and hsl() can only describe sRGB. OKLCH can also describe Display P3 and wider colors, so some OKLCH values have no exact HEX. For those, the converter lowers chroma while keeping lightness and hue (the CSS Color 4 method) and shows the plain clipped HEX next to it. To support old browsers, write the HEX first:

.button {
  background: #3b82f6;
  background: oklch(62.31% 0.188 259.81);
}

Browsers that do not understand oklch() ignore the second line and keep the HEX.

Browser Support for oklch()

BrowserFirst version with oklch()
Chrome and Edge111
Safari (macOS and iOS)15.4
Firefox113

Frequently Asked Questions

How can I convert a HEX color to OKLCH?

Paste the HEX code into the converter and read the oklch() value. For example, #ff0000 becomes oklch(62.8% 0.2577 29.23). Under the hood the HEX is turned into sRGB, linearized, converted to XYZ and then to LMS cone responses, cube-rooted into OKLab, and finally written in polar form: lightness L, chroma C and hue H. Every HEX color sits inside sRGB, so the result is exact and converts back to the same HEX.

How can I convert OKLCH colors to RGB colors?

Open the From OKLCH tab, enter L, C and H, and copy the rgb() or HEX row. You can also paste an oklch() value into the main box on the To OKLCH tab. The math runs the other way: OKLCH to OKLab, then LMS, XYZ and linear sRGB, then gamma encoding and a scale to 0 to 255. If a channel lands outside that range the color is outside sRGB, so the converter gamut-maps it instead of just clamping.

What is the OKLCH color format?

OKLCH is a perceptual CSS color format written as oklch(L C H / alpha). L is lightness from 0% to 100%, C is chroma (roughly 0 to 0.4) and H is a hue angle from 0 to 360 degrees. It is built on Oklab, so equal changes in L look like equal changes in brightness, which makes scales, themes and gradients easier to control than with HSL. Tailwind CSS v4 defines its default palette in OKLCH.

What is the difference between LCH and OKLCH?

Both use lightness, chroma and hue, but on different color spaces. LCH is based on CIE Lab and OKLCH is based on Oklab. OKLCH fixes the hue shift that makes LCH blues turn purple and predicts lightness more evenly. OKLCH lightness runs from 0 to 1 and chroma stays under about 0.4, while LCH lightness runs from 0 to 100 and chroma reaches about 150. For new palettes, OKLCH is the better choice.

Why does my OKLCH color have no exact HEX?

HEX can only describe sRGB, but OKLCH can describe wider gamuts such as Display P3. A vivid color like oklch(70% 0.35 145) is outside sRGB, so any HEX is an approximation. The converter shows the CSS Color 4 gamut-mapped HEX, which keeps lightness and hue, next to the plain clipped HEX, so you can compare them.

Can I convert RGBA, HSLA and transparent colors to OKLCH?

Yes. Alpha is carried through every format. rgba(255, 0, 0, 0.5) becomes oklch(62.8% 0.2577 29.23 / 50%), and the HEX output becomes 8 digits (#ff000080). Opacity is separate from the color, so lightness, chroma and hue do not change.

Landing page templates from CSS Toolkit