hex to GLSL vec3

Divide each byte by 255 and you get the encoded values shown here. If the color feeds lighting or blending math you want the linear row instead, because shader math assumes linear light.

Paste a hex value. Other formats work too.

GLSL vec3
vec3(0.0, 0.671, 0.906)

Need every format at once? Open in the full picker

Worked examples

Common colors converted from hex to GLSL vec3, computed with the same engine the picker uses.

ColorhexGLSL vec3Copy
Pure red#ff0000vec3(1.0, 0.0, 0.0)
Pure green#00ff00vec3(0.0, 1.0, 0.0)
Pure blue#0000ffvec3(0.0, 0.0, 1.0)
White#ffffffvec3(1.0)
Mid gray#808080vec3(0.502)
Black#000000vec3(0.0)
Interface blue#4287f5vec3(0.259, 0.529, 0.961)
Success green#22c55evec3(0.133, 0.773, 0.369)
Danger red#ef4444vec3(0.937, 0.267, 0.267)
Warning amber#f59e0bvec3(0.961, 0.62, 0.043)
Editor black#1e1e1evec3(0.118)
Warm sand#e9c46avec3(0.914, 0.769, 0.416)

How the conversion works

Divide each byte by 255 and you get the encoded values shown here. If the color feeds lighting or blending math you want the linear row instead, because shader math assumes linear light.

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 color that cannot be represented in the target format is handled deliberately rather than by accident.

When the source describes a color 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 colors.

Related conversions