hex to linear GLSL vec3
This applies the sRGB inverse transfer function, so the numbers are lower than a plain division by 255. Use these when the value enters lighting, blending or filtering.
vec3(0.054, 0.242, 0.913)Paste a hex value — other formats work too.
Need every format at once? Open in the full picker
Worked examples
Common colours converted from hex to linear GLSL vec3, computed with the same engine the picker uses.
| Colour | hex | linear GLSL vec3 | Copy |
|---|---|---|---|
| Pure red | #ff0000 | vec3(1.0, 0.0, 0.0) | |
| Pure green | #00ff00 | vec3(0.0, 1.0, 0.0) | |
| Pure blue | #0000ff | vec3(0.0, 0.0, 1.0) | |
| White | #ffffff | vec3(1.0) | |
| Mid grey | #808080 | vec3(0.216) | |
| Black | #000000 | vec3(0.0) | |
| Interface blue | #4287f5 | vec3(0.054, 0.242, 0.913) | |
| Success green | #22c55e | vec3(0.016, 0.558, 0.112) | |
| Danger red | #ef4444 | vec3(0.863, 0.058, 0.058) | |
| Warning amber | #f59e0b | vec3(0.913, 0.342, 0.003) | |
| Editor black | #1e1e1e | vec3(0.013) | |
| Warm sand | #e9c46a | vec3(0.815, 0.552, 0.144) |
How the conversion works
This applies the sRGB inverse transfer function, so the numbers are lower than a plain division by 255. Use these when the value enters lighting, blending or filtering.
Both formats are computed from a single canonical representation — CIE XYZ with a D65 white point, held in floating point — rather than by chaining one format into the next. That matters because chained conversions accumulate rounding error, and because it means a colour that cannot be represented in the target format is handled deliberately rather than by accident.
When the source describes a colour outside the target's gamut, chroma is reduced in OKLCh while lightness and hue are held, following the CSS Color 4 gamut mapping algorithm. Clipping each channel independently would be simpler but visibly shifts hue on saturated colours.