Primitive Color CIELAB (MD)
L*a*b* to hex
- int
- HEX
CIELAB, or L*a*b*, is the color space designed to match how humans actually perceive color differences - which is why color scientists, paint brands and color-matching tools report colors in it. It's also cryptic if you've never met it. mdPrimitiveColorLAB is the bridge: feed it an L, an a and a b, and it gives you a packed RGB integer and a #RRGGBB hex string, so a measured LAB value can become a color in your workflow.
How it works
The three components mean:
- L - lightness, 0 (black) to 100 (white). The only input that's intuitive at a glance.
- a - the green–red axis. Negative is green, positive is red, 0 is neutral.
- b - the blue–yellow axis. Negative is blue, positive is yellow, 0 is neutral.
The node converts LAB back to XYZ against the D65 white point, then XYZ to sRGB with the standard matrix and gamma curve, then packs as (R << 16) | (G << 8) | B. Same output contract as the rest of the primitive color family.
The inputs and outputs
L- 0 to 100, default 50.A- −128 to 128, default 0. The green–red axis.B- −128 to 128, default 0. The blue–yellow axis.- Output
int- packed color integer (0–16777215). - Output
HEX- hex string.
The defaults - L 50, a 0, b 0 - give you a neutral mid-gray, which is a good first test: you should get a gray, not a colored surprise.
Install
Part of MdColorMod, zero dependencies, no models:
cd ComfyUI/custom_nodes
git clone https://github.com/MdONeilsl/ComfyUI-MdColorMod
Restart ComfyUI, or install via ComfyUI Manager by searching "MdColorMod".
Where people get burned
Two things. First, the a and b axes can genuinely surprise: positive a is red and positive b is yellow, and lots of people have them backwards for the first week. Second, like XYZ, LAB can express colors sRGB can't - a very saturated measured color will clip to the nearest displayable shade, and that's the conversion working as intended. If you're picking colors casually rather than translating measurements, the HSL or HSV primitives in this pack will be kinder.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| L | FLOAT | 50.00–100 | Lightness component (0-100). |
| A | FLOAT | 0.0-128–128 | A component (green-red axis). |
| B | FLOAT | 0.0-128–128 | B component (blue-yellow axis). |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| int | INT | Packed 24-bit integer color value (0-16777215). |
| HEX | STRING | Hexadecimal color string (e.g., #FF0000). |