CIE XYZ to RGB Color Converter

Convert CIE XYZ tristimulus values back to sRGB

Convert CIE XYZ tristimulus values under the D65 illuminant back to sRGB and hex, with a gamut warning when the result falls outside the sRGB triangle. The inverse of the RGB-to-XYZ transform. Runs in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

How is XYZ converted back to sRGB?

The X, Y, Z values are divided by 100, multiplied by the inverse sRGB-to-XYZ matrix to get linear RGB, then each channel is gamma-encoded with the sRGB transfer function and scaled to 0 to 255. This is the exact reverse of the forward transform.

Convert CIE XYZ back to sRGB

This is the inverse of the RGB-to-XYZ transform: it takes device-independent CIE XYZ tristimulus values and turns them back into displayable sRGB and hex. It is the final step when you have worked in a perceptual space such as Lab or have measured a color with a colorimeter and need a value you can actually paint to screen. A built-in gamut check flags colors that sRGB cannot reproduce.

How it works

The X, Y, Z inputs are divided by 100 to put them on a 0–1 scale, then multiplied by the inverse sRGB matrix for the D65 white point:

R =  3.2404542*X - 1.5371385*Y - 0.4985314*Z
G = -0.9692660*X + 1.8760108*Y + 0.0415560*Z
B =  0.0556434*X - 0.2040259*Y + 1.0572252*Z

Those linear values are gamma-encoded with the sRGB transfer function — 1.055 * c^(1/2.4) - 0.055 above 0.0031308, otherwise c * 12.92 — and scaled to 0–255. If any linear channel lands below 0 or above 1, the color sits outside the sRGB gamut and is clamped.

Where XYZ values come from

You encounter raw XYZ values in a few workflows:

  • CIE Lab conversion. Lab and LCH are perceptual spaces defined relative to XYZ. When you use a design tool or color library to convert Lab to a displayable color, it passes through an intermediate XYZ representation. Knowing what that intermediate looks like helps when debugging unexpected hue shifts.
  • Colorimeter output. Physical color measurement instruments (spectrophotometers, colorimeters) typically report their measurements as XYZ tristimulus values relative to a chosen illuminant. Converting to sRGB lets you preview the measured color on screen.
  • ICC color profiles. ICC profiles use XYZ as the profile connection space (PCS). Understanding the XYZ-to-RGB step clarifies why colors look different when rendering across profiles.

Worked example

For example, the XYZ values X = 41.24, Y = 21.26, Z = 1.93 (relative to D65 where Y = 100) lie in the red region of the spectrum. After dividing by 100, multiplying by the inverse matrix, applying gamma, and scaling:

  • The linear red channel comes out above 1.0, meaning the color is more saturated than sRGB can show on that channel.
  • The converter clamps it and flags the result as out of gamut.
  • The resulting hex is a saturated red, but it is the closest sRGB approximation, not the exact color.

Contrast this with the D65 white X = 95.05, Y = 100.00, Z = 108.88, which converts cleanly to #ffffff with all channels at exactly 255.

Out-of-gamut colors: what they mean

The sRGB gamut is a triangle of colors that a typical display can reproduce. Many colors a human can see lie outside that triangle — particularly deep cyans, saturated greens, and ultra-vivid spectral hues. When XYZ values map to a linear RGB channel value below 0 or above 1, those values represent those out-of-gamut colors. Clamping to 0–255 gives the closest in-gamut approximation, which is useful for a preview but not accurate color reproduction. If accuracy matters, the correct approach is to use a wider-gamut space (Display P3, Adobe RGB) or work with the XYZ values directly in a system that supports them.

Scale and white-point assumptions

This tool expects the Y = 100 scale (matching the common CIE Lab convention) and the D65 illuminant. If your XYZ values are on a 0–1 scale, multiply each by 100 first. If they were measured under a different illuminant (D50, A, F2), they need chromatic adaptation before this converter will give accurate results.