Skip to content
colors

xyzToLab

The `xyzToLab` function converts CIE XYZ tristimulus values into the CIE Lab color space. Lab is designed to be perceptually uniform, making it ideal for comparing colors based on human vision.

1 min read194 words

Function Signature

js

xyzToLab(X: number, Y: number, Z: number): { L: number, a: number, b: number }

Parameters

  • X (number): The X tristimulus value relative to D65 reference white.
  • Y (number): The Y tristimulus value relative to D65 reference white.
  • Z (number): The Z tristimulus value relative to D65 reference white.

Return Value

An object representing Lab components: L (lightness, 0–100), a (green–red axis), and b (blue–yellow axis).

js

xyzToLab(48.4, 30.3, 4.0);
// { L: ~62, a: ~58, b: ~70 }

xyzToLab(35.8, 41.4, 98.5);
// { L: ~66, a: ~-7, b: ~-41 }

Conversion Details

  • Uses the D65 reference white (Xn=95.047, Yn=100.0, Zn=108.883).
  • Applies a piecewise function f(t) to normalize XYZ values:
  • f(t) = t^(1/3) if t > 0.008856, otherwise 7.787 * t + 16/116.
  • L = 116 * fy - 16
  • a = 500 * (fx - fy)
  • b = 200 * (fy - fz)

Examples

js

// Convert white reference
console.log(xyzToLab(95.047, 100.0, 108.883));
// { L: 100, a: 0, b: 0 }

// Convert black
console.log(xyzToLab(0, 0, 0));
// { L: 0, a: 0, b: 0 }

Error Handling

If any of the parameters are not numbers, the function returns { L: 0, a: 0, b: 0 }.

Usage Notes

  • Lab values are device-independent and useful for perceptual comparisons.
  • Commonly used with rgbToLab and labToRgb for conversions between RGB and Lab.
  • Supports ΔE (color difference) calculations when paired with another Lab value.

Previous

rgbToXyz

Next

rgbToLab


Top tools

WorkspaceLinksySEO AnalyzerChromoQR Code Generator

ReadyTools

CareersContactTools
Pricing7 days free
SupportSecurityGuidesDocsBlogUpdatesLaraVault

Select Language

Set theme

ReadyTools

© 2026 ReadyTools. All rights reserved.