OKLab to HEX Converter

Converted HEX Output --
100%

Wide-Gamut & Linear Formats

Modern CSS color space notations derived from this color

Contrast Analysis (WCAG 2.1)

Checks the converted color against foreground or background targets for accessibility compliance.

How to Convert OKLab to HEX

Converting OKLab to a HEX code requires translating a modern, perceptually uniform color space into the standard, sRGB-bound format used by legacy web browsers.

The Gamut Clipping Problem

OKLab is a wide-gamut color space capable of describing any color the human eye can see. HEX codes are strictly tied to the sRGB color space, which is much smaller. If you have a highly vibrant OKLab color, it physically cannot be represented as a HEX code.

During the conversion process, if the OKLab color falls outside the sRGB gamut, the algorithm must clamp or map the color to the closest available sRGB value. This means the resulting HEX code will look slightly less vibrant than the original OKLab color.

The Conversion Pipeline

To get from OKLab to HEX, the color must pass through several intermediate spaces:

  1. OKLab to Linear RGB: The L, a, and b values are multiplied by an inverse matrix to convert them from LMS cone space back into linear red, green, and blue light.
  2. Gamma Correction: The linear RGB values are passed through the sRGB gamma curve to match how monitors display light.
  3. RGB to HEX: The final RGB decimals (0-255) are converted into base-16 hexadecimal strings and combined.

Related Tools