Color converter
HEX to XYZ and XYZ to HEX
Type a HEX value or an XYZ value, and the other one appears as you type. Every other notation of the same color is listed below, with each step of the maths.
The converter needs JavaScript. The values shown are for #D3AF37, and the worked examples below read without it.
Result
Inside sRGB
Showing the last color that converted.
- HEX
#D3AF37- XYZ
color(xyz-d65 0.42882 0.44786 0.1)- RGB
rgb(211 175 55)- HSL
hsl(46.2 63.9% 52.2%)- OKLCH
oklch(76.55% 0.13847 91.55)
Color converters
Every format at once
The same color in every notation the converters know. Each name opens its own converter.
| Format | Value | Copy |
|---|---|---|
| Web and CSS | ||
| HEX CSS | #D3AF37 | |
| RGB CSS | rgb(211 175 55) | |
| sRGB (0 to 1) CSS | color(srgb 0.8275 0.6863 0.2157) | |
| Linear sRGB CSS | color(srgb-linear 0.65141 0.42869 0.0382) | |
| HSL CSS | hsl(46.2 63.9% 52.2%) | |
| HSV (HSB) Notation | hsv(46.2 73.9% 82.7%) | |
| HWB CSS | hwb(46.2 21.6% 17.3%) | |
| CSS color name CSS | goldenrodNearest ΔE00 5.00 | |
| Perceptual and CIE | ||
| OKLCH CSS | oklch(76.55% 0.13847 91.55) | |
| OKLab CSS | oklab(76.55% -0.00375 0.13842) | |
| CIELAB CSS | lab(73.19 4.7 62.68) | |
| CIE LCH CSS | lch(73.19 62.86 85.71) | |
| CIE XYZ (D65) CSS | color(xyz-d65 0.42882 0.44786 0.1) | |
| CIE XYZ (D50) CSS | color(xyz-d50 0.45463 0.45457 0.07797) | |
| CIE xyY Notation | xyY(0.43906 0.45855 0.44786) | |
| CIELUV Notation | luv(72.75 30.75 69) | |
| Wide gamut | ||
| Display P3 CSS | color(display-p3 0.80472 0.69157 0.30739) | |
| Rec. 2020 CSS | color(rec2020 0.74174 0.66017 0.25864) | |
| Adobe RGB (1998) CSS | color(a98-rgb 0.78545 0.68035 0.26584) | |
| ProPhoto RGB CSS | color(prophoto-rgb 0.67408 0.63343 0.26964) | |
| Print and paint | ||
| CMYK Notation | cmyk(0% 17.1% 73.9% 17.3%) | |
| RAL Classic Notation | RAL 1032 Broom yellowNearest ΔE00 3.02 | |
| Video | ||
| YCbCr (JPEG, BT.601) Notation | ycbcr(172.08 61.93 155.76) | |
| YCbCr (HD video, BT.709) Notation | ycbcr709(165.43 71.67 148.64) | |
| Code and platforms | ||
| Decimal integer Notation | 13872951 | |
| Android and Flutter ARGB Notation | 0xFFD3AF37 | |
| Android color int Notation | -2904265 | |
| SwiftUI and UIKit Notation | Color(red: 0.8275, green: 0.6863, blue: 0.2157) | |
| GLSL vec3 / vec4 Notation | vec3(0.8275, 0.6863, 0.2157) | |
| Embedded and terminal | ||
| RGB565 Notation | 0xD567Lossy | |
| ANSI 256 (xterm) Notation | 38;5;178Nearest ΔE00 3.11 | |
Every step of the maths
How HEX becomes XYZ
Each step shows the values for the color above, as the converter computes them.
- Start Hex digits
#D3AF37 - Back 8-bit channels
each pair of digits read as a byte211 175 55 - Back sRGB channels, 0 to 1
each byte ÷ 2550.8275 0.6863 0.2157 - Then Linear light
c ≤ 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055)^2.40.65141 0.42869 0.0382 - Then CIE XYZ, D65
the sRGB to XYZ matrix0.42882 0.44786 0.1
XYZ
About XYZ
CIE XYZ is the space every other one here is defined through: Y is luminance, and X and Z carry the rest of the color. CSS reads it as color(xyz-d65 …), with Y from 0 for black to 1 for white.
How this page writes it
- Linear sRGB is multiplied by the sRGB to XYZ matrix, built from the sRGB primaries and the D65 white.
- Written to five decimal places.
Watch for
- Some tools scale XYZ so that white has Y = 100; here and in CSS, white has Y = 1.
Worked examples
HEX to XYZ
Each row is the converter's own output, and a test re-runs every row.
| Color | HEX | XYZ |
|---|---|---|
| White | #FFFFFF | color(xyz-d65 0.95046 1 1.08906) |
| Black | #000000 | color(xyz-d65 0 0 0) |
| Middle gray | #808080 | color(xyz-d65 0.20517 0.21586 0.23508) |
| Red | #FF0000 | color(xyz-d65 0.41239 0.21264 0.01933) |
| Green | #00FF00 | color(xyz-d65 0.35758 0.71517 0.11919) |
| Blue | #0000FF | color(xyz-d65 0.18048 0.07219 0.95053) |
| Royal blue | #2563EB | color(xyz-d65 0.20218 0.15314 0.8049) |
| Gold | #D3AF37 | color(xyz-d65 0.42882 0.44786 0.1) |
Next
Related converters
- HEX and RGBHex codes, rgb() and alpha
- HEX and OKLCHPerceptual color and gamut
- XYZ and LabCIELAB in D50, as CSS lab()
- HEX and OKLabPerceptual lightness and two opponent axes
- HEX and LabCIELAB in D50, as CSS lab()
- HEX and LCHCIELAB as lightness, chroma and hue
- All color convertersPaste a color in any notation the converters read, and see it in all of them.
Method
Sources and testing
- CSS Color Module Level 4, 10.8: the predefined CIE XYZ color spaces w3.org
- CIE 15:2018, Colorimetry cie.co.at
- Conversions run in your browser with the site's shared color code; nothing you type is sent anywhere.
- An automated test recomputes every value on this page and reads every format back.
- Checked with a keyboard, the axe engine and Playwright in Chromium, in light and dark themes at phone and desktop widths. It has not yet been checked with a screen reader.
Found a mistake? Tell us and we will correct it.