OKLab Color Converter
Convert between OKLab, OKLCH, HEX, RGB, HSL, and CSS oklab() in real time. Drag the L, a, and b sliders to fine-tune perceptual color.
Inputs
OKLab sliders
OKLab input
OKLCH input
All conversions
Saved swatches
No saved swatches yet. Save a color to compare lightness, chroma, and hue side by side.
What is an OKLab color converter?
An OKLab color converter translates between OKLab, OKLCH, HEX, RGB, HSL, and CSS oklab() values. OKLab is a perceptual color space published by Björn Ottosson that describes a color with lightness (L), a green-to-red axis (a), and a blue-to-yellow axis (b). Equal numeric steps in OKLab look equal to the human eye, which makes it the best space for palettes, gradients, and accessible color work.
Key takeaways
- OKLab describes color with L (lightness), a (green to red), and b (blue to yellow).
- OKLCH is the same color in polar form: L, C (chroma), H (hue).
- This converter updates every format live as you type or drag sliders.
- Out-of-gamut values are flagged with the closest displayable HEX.
- Copy oklab(), oklch(), HEX, rgb(), or hsl() with one click.
- Save swatches to compare lightness, chroma, and hue side by side.
How to use the OKLab color converter
Every field is synchronized. Enter a value in any format and every other format updates instantly.
- Pick any input formatStart from HEX, RGB, HSL, OKLab, or OKLCH. Every field updates live, so you can enter a value in whichever format you already have.
- Drag the L, a, and b slidersAdjust perceptual lightness (L), the green-to-red axis (a), and the blue-to-yellow axis (b). The preview and every other format update together.
- Watch the gamut warningOKLab can describe colors sRGB cannot display. The tool flags out-of-gamut values and shows the closest displayable HEX.
- Read the OKLCH equivalentEvery OKLab value has an OKLCH twin with the same lightness and hue. Use OKLCH when you want to talk about hue and chroma separately.
- Copy ready-to-paste CSSCopy oklab(), oklch(), HEX, rgb(), or hsl() with one click. Every value is CSS Color Module Level 4 compatible.
- Save and compare swatchesSave colors to a side-by-side strip to compare lightness, chroma, and hue, and export the strip as JSON.
OKLab vs OKLCH vs HSL vs RGB
Each color space answers a different question. Choose the one that matches the task.
| Space | Coordinates | Best for |
|---|---|---|
| OKLab | L (0 to 1), a (-0.4 to 0.4), b (-0.4 to 0.4) | Interpolation, matrix math, gamut mapping, design tokens |
| OKLCH | L, C (chroma), H (hue in degrees) | Hue rotation, chroma control, palette generation |
| HSL | H, S (saturation %), L (lightness %) | Quick familiar tweaks, but not perceptually uniform |
| RGB | R, G, B (0 to 255) | Device output, canvas, image data |
| HEX | 6-digit sRGB | CSS, design tools, shorthand |
Why OKLab is perceptual
HSL and RGB are not perceptually uniform. In HSL, two colors with the same numeric lightness can look completely different in brightness. OKLab fixes this because it was designed around human vision. When you change L from 0.4 to 0.5, the color gets noticeably brighter in a way that feels consistent across every hue.
This is why OKLab is the best space for building color scales. A Tailwind-style 50 to 950 ramp generated in OKLab has even visual steps, while a ramp generated in HSL often collapses at the light and dark ends. If you want to explore the same colors with a hue wheel, use the OKLCH Color Picker.
Understanding the a and b axes
The a axis runs from green (negative) to red (positive). The b axis runs from blue (negative) to yellow (positive). The two axes are independent, which is what makes OKLab easy to interpolate.
- a ≈ 0, b ≈ 0 — a neutral grey of the given lightness.
- Positive a — pushes toward red, pink, and orange.
- Negative a — pushes toward green and teal.
- Positive b — pushes toward yellow and gold.
- Negative b — pushes toward blue and violet.
Chroma in OKLCH is the distance from the origin of a and b: C = sqrt(a² + b²). Hue is the angle: H = atan2(b, a). Both are shown live in the preview above.
What about sRGB gamut?
OKLab and OKLCH describe more colors than any sRGB screen can display. If you push a or b far enough, the equivalent sRGB color does not exist and the value is out of gamut. This converter handles that gracefully: it detects overflow, lowers chroma until the color fits, and shows the closest displayable HEX. This is the same gamut-mapping strategy used by CSS Color Module Level 4.
If you see the gamut warning, treat it as a hint: keep lightness and hue where they are and reduce chroma. This keeps the color family and only softens the saturation, which is usually what you want for accessible palettes.
Using OKLab in CSS
CSS Color Module Level 4 defines oklab() and oklch() as native color functions. Chrome, Edge, Firefox, and Safari support both. This converter copies ready-to-use CSS:
oklab(0.65 -0.09 -0.05)— L, a, b with optional alpha.oklch(0.65 0.11 190)— L, chroma, hue with optional alpha.
Both functions accept a slash alpha: oklch(0.65 0.11 190 / 0.5). Use @supports (color: oklch(0 0 0)) if you need a HEX fallback for older browsers. To build a full Tailwind theme with OKLab values, use the Tailwind Shade Generator.
Common OKLab use cases
| Task | Why OKLab helps |
|---|---|
| Color scales | Even perceptual steps across the entire 50 to 950 range. |
| Gradients | Interpolation does not pass through muddy grey or dark mid-tones. |
| Theme switching | Change lightness only and keep hue and chroma intact, which keeps brand identity. |
| Accessibility | Adjust lightness to hit contrast targets without shifting hue. |
| Design tokens | Emit OKLab and OKLCH tokens that every modern tool reads natively. |
Common mistakes
- Treating OKLab L as HSL L. They are different scales. HSL L is 0 to 100; OKLab L is 0 to 1 and follows perception.
- Ignoring the gamut warning. An out-of-gamut value looks fine in OKLab but cannot be shown on an sRGB screen. Always check the clamped HEX.
- Mixing spaces in a palette. Pick one space for a scale and stick with it. OKLab is the safest choice.
- Rotating hue without checking chroma. Some hues have much smaller maximum chroma than others. Chroma that works at red may clip at blue.
- Assuming OKLab replaces contrast checks. Perceptual lightness is not the same as WCAG contrast. Test with the Color Contrast Checker.
Frequently asked questions
What is OKLab?
OKLab is a perceptual color space published by Björn Ottosson in 2020. It describes a color with three numbers: L (lightness), a (the green to red axis), and b (the blue to yellow axis). Equal numeric steps in OKLab look equal to the human eye, which makes it far better than HSL or RGB for building palettes, gradients, and accessible interfaces.
How is OKLab different from OKLCH?
OKLab and OKLCH describe the same color. OKLab uses Cartesian coordinates (L, a, b), while OKLCH uses polar coordinates (L, C, H) where C is chroma and H is hue. OKLab is easier for interpolation and matrix math; OKLCH is easier to read and to reason about hue and saturation.
How do I convert HEX to OKLab?
Paste the HEX code into the HEX field. The tool converts the sRGB color to linear sRGB, applies the OKLab matrix, and displays L, a, and b. Every other format (RGB, HSL, OKLCH, CSS) updates at the same time.
How do I convert OKLab to HEX?
Enter the L, a, and b values or drag the sliders. The tool converts OKLab back to linear sRGB and then to a displayable HEX. If the result falls outside the sRGB gamut, the tool shows the closest HEX and flags the overflow.
What is the OKLab range for L, a, and b?
L runs from 0 (black) to 1 (white). The a axis runs roughly from -0.4 (green) to 0.4 (red). The b axis runs roughly from -0.4 (blue) to 0.4 (yellow). In practice most sRGB colors fall within L 0 to 1 and a, b between -0.3 and 0.3.
Why is my OKLab color out of gamut?
The OKLab color space covers more colors than any sRGB screen can display. If you set an extremely saturated a or b value, the equivalent sRGB color does not exist. The tool clamps the color to the gamut and warns you so you can lower chroma while keeping lightness and hue.
Can I use oklab() in CSS?
Yes. CSS Color Module Level 4 defines oklab() and oklch() and all current major browsers support both. This tool copies valid oklab(L a b) and oklch(L C H) values that you can drop into any stylesheet or Tailwind theme.
What is OKLab good for?
OKLab is the best space for palette generation, gradient interpolation, color scales, and accessibility work. Designers use it to build brand ramps, Tailwind-style scales, and smooth gradients that do not pass through muddy grey.
Is the OKLab color converter free?
Yes. The tool is free, needs no account, and runs entirely in your browser. Your colors are never uploaded.
Which browsers support OKLab?
Chrome, Edge, Firefox, and Safari all support oklab() and oklch() in CSS. Older browsers may fall back to the HEX value, so this tool gives you HEX, rgb(), and hsl() as well.
What are typical OKLab values for a primary brand color?
A saturated blue sits around L 0.45, a -0.03, b -0.28. A warm red sits around L 0.55, a 0.20, b 0.11. A neutral grey has a and b close to 0. The tool shows these live as you drag the sliders.
How does this tool handle rounding?
OKLab values are shown to four decimal places, which is enough precision for CSS and design tokens. HEX is rounded to 8-bit sRGB channels. Round-tripping from OKLab to HEX and back is accurate to within the sRGB step size.