HEX to OKLCH Converter

Convert HEX to OKLCH for modern CSS and Tailwind CSS v4. Paste a hex code and copy the oklch() value, or paste oklch() to get the hex code back.

Paste a hex code to convert it to OKLCH, or an oklch() value such as oklch(51.1% 0.262 276.97) to convert it to hex.

OKLCH value

Lightness, chroma and hue
L0% black → 100% white
C0 gray → about 0.37 most vivid
HHue angle, 0–360°
CSS with a hex fallback

                        
All color formats
HEX
HEX + alpha
RGB
RGBA
HSL
OKLCH
Tailwind

Convert Hex Colors to OKLCH Online

OKLCH is the color format behind modern CSS color work and the default palette of Tailwind CSS v4. This converter turns any hex code into an oklch() value with its lightness, chroma and hue, and turns oklch() values back into hex.

Because OKLCH matches how people actually see lightness, it makes it easy to build even color scales, adjust shades without hue shifts and create accessible palettes. The conversion uses the official OKLab formulas and runs entirely in your browser.

Hex color code converted to an OKLCH value#4F46E5oklch(51% 0.23 277)HEX to OKLCHConverter

How to convert HEX to OKLCH

  1. Paste the hex code, for example #4F46E5, or pick a color.
  2. Copy the OKLCH value, such as oklch(51.06% 0.2301 276.97), or the CSS snippet with a hex fallback.
  3. Going the other way? Paste an oklch() value into the same field to get its hex, RGB and HSL values.

What is OKLCH?

OKLCH describes a color with three numbers, based on the OKLab color space created by Björn Ottosson in 2020:

PartMeaningRange
L – LightnessHow light the color looks to the human eye0% (black) to 100% (white)
C – ChromaHow vivid or saturated the color is0 (gray) to about 0.37
H – HueThe color angle on the color wheel0 to 360 degrees

An optional alpha follows a slash: oklch(51% 0.23 277 / 0.5).

Why use OKLCH instead of HEX or HSL?

  • Lightness you can trust: in HSL, yellow hsl(60, 100%, 50%) and blue hsl(240, 100%, 50%) both have 50% lightness, yet yellow looks far brighter. In OKLCH they are 96.8% and 45.2%, which matches what you see.
  • Even color scales: keep the hue and chroma and step the lightness to build a palette whose shades look evenly spaced.
  • No hue shifts: darkening or lightening a color in OKLCH keeps it the same hue, unlike HSL where blues can drift towards purple.
  • Wide-gamut colors: OKLCH can describe the more vivid colors of Display P3 screens that hex and rgb() cannot.

OKLCH in Tailwind CSS v4

Tailwind CSS v4 defines its whole default palette in OKLCH. For example indigo-600 is oklch(51.1% 0.262 276.966), which displays as #4F39F6 on standard screens. To add your own brand color in the same format, convert it here and put it in your theme:

@theme { --color-brand: oklch(51.06% 0.2301 276.97); }

Then use it like any other color: bg-brand, text-brand/80. Browse the Tailwind CSS color palette for ready-made shades.

Browser support and fallbacks

oklch() works in Chrome and Edge 111+, Firefox 113+ and Safari 15.4+, so it is safe for most audiences today. For older browsers, declare the hex color first and the OKLCH color second; browsers that do not understand OKLCH keep the hex value:

color: #4F46E5; color: oklch(51.06% 0.2301 276.97);

When you paste an OKLCH value that is outside the sRGB range, the converter shows the closest displayable hex color and tells you it was adjusted.

Frequently Asked Questions

Common questions about converting hex colors to OKLCH.

Paste the hex code above and copy the oklch() value. Behind the scenes the color is converted from sRGB to linear RGB, then to OKLab, and finally to lightness, chroma and hue.

OK is the name of the OKLab color space it is based on, and LCH stands for lightness, chroma and hue.

For design work, usually yes. OKLCH lightness matches how bright colors look to people, so palettes and contrast are much more predictable than with HSL.

Hex codes store whole numbers from 0 to 255, so tiny rounding differences can appear. If the OKLCH color is outside the sRGB range, the nearest displayable color is used.

Yes. The default Tailwind CSS v4 palette is written in OKLCH, and you can define your own colors with oklch() in the @theme block.

All current versions of Chrome, Edge, Firefox and Safari support oklch(). Add a hex fallback before it if you need to support older browsers.

Yes. Paste any oklch() value into the field and the hex, RGB and HSL values appear instantly.