Skip to content
Hex Calculator

OKLab to Hex Converter

Convert an OKLab lightness and a/b coordinate pair back into a 6-digit hex color code, with exact round-trip accuracy for design tokens.

Hex result
#2563EB

How OKLab to Hex Conversion Works

The lightness and a/b coordinates run through the inverse of the Oklab matrix transform to produce linear-light RGB. That linear RGB is then gamma-encoded into standard sRGB and rounded to 0-255 integer channels, which convert to hex the same way any RGB to hex conversion works.

OKLab to Hex Example, Step by Step

oklab(54.6% -0.0267 -0.2135) = #2563EB

oklab(54.6% -0.0267 -0.2135) = #2563EB

Oklab(0.546, -0.0267, -0.2135)
-> inverse Oklab matrix -> LMS
-> inverse LMS matrix -> linear RGB
-> sRGB gamma encoding

Round to bytes: R=37, G=99, B=235 -> #2563EB
StepDescriptionResult
Apply the inverse Oklab matrixmap L, a, b back to LMSL, M, S values
Apply the inverse LMS matrixmap LMS back to linear RGBlinear R, G, B
Apply sRGB gamma encodingconvert linear values to standard sRGBR=37, G=99, B=235
Convert to hexround and pair each channel#2563EB

This exactly reverses the hex-to-OKLab example — the two conversions are precise inverses of each other for in-gamut colors.

Common Mistakes With OKLab to Hex

  • Entering a or b as percentages — they're signed decimals, typically roughly -0.4 to 0.4, not 0-100% values.
  • Expecting every L/a/b combination to map to a valid hex — some fall outside what sRGB can display and get clamped.
  • Mixing up a and b — a is the green-red axis, b is the blue-yellow axis; swapping them produces a completely different hue.

Frequently Asked Questions

How do you convert OKLab to hex?

Run the Oklab matrix transform in reverse to get linear-light RGB from the L, a, and b values, then apply sRGB gamma encoding and round each channel to a 0-255 integer before converting to hex.

What format does this tool accept for OKLab input?

Either plain space-separated values (54.6% -0.0267 -0.2135) or a full oklab() function string (oklab(54.6% -0.0267 -0.2135)) — both work the same.

Does OKLab to hex round-trip exactly?

Yes — oklab(54.6% -0.0267 -0.2135) converts back to exactly #2563EB, matching the original hex value it came from with no drift.

What happens with an OKLab color outside the sRGB gamut?

Some L/a/b combinations represent colors no sRGB screen can display. This tool clamps the output to the nearest valid 0-255 RGB channel values rather than producing an invalid hex code.

Can a and b be positive or negative?

Yes — both axes are signed. Positive a leans red, negative a leans green; positive b leans yellow, negative b leans blue.