RGB 0–1 ↔ HEX

Game engines and shaders store color as 0.0–1.0. CSS and most design tools want #RRGGBB. This maps one to the other.

How to use the RGB 0–1 ↔ HEX

What does the RGB 0–1 ↔ HEX do?

Convert shader-style RGB floats (0–1) to 8-bit hex and back; It applies this page-specific rule: each channel is clamped to 0–1, multiplied by 255, and rounded to the nearest integer.

Which inputs does this tool use?

To convert shader-style rgb floats (0–1) to 8-bit hex and back, enter RGB 0–1 (or a vec3), HEX; keep every value in the same example; the page then updates the result from the current values; Start with a familiar case covered by this rule - Ordinary HEX ↔ RGB pages ignore this - so the expected result can confirm the settings.

How should the tool result be read?

For a result intended to convert shader-style rgb floats (0–1) to 8-bit hex and back, ordinary HEX ↔ RGB pages ignore this; read hex together with the original rgb 0–1 (or a vec3) rather than as an isolated answer, and confirm that its units or structure match the intended use.

Inclusive 1.0?

When the goal is to convert shader-style rgb floats (0–1) to 8-bit hex and back, yes.

Can I paste “vec3(0.2, 0.4, 0.8)”?

When using the page to convert shader-style rgb floats (0–1) to 8-bit hex and back, the three numbers are pulled out of the text.

Limits and accuracy

When using this tool to convert shader-style rgb floats (0–1) to 8-bit hex and back, no linear-to-sRGB transfer is applied; check the result in its intended destination before relying on it for important work; keep rgb 0–1 (or a vec3) until the output has been checked in its intended destination. For a repeatable check when you need to convert shader-style rgb floats (0–1) to 8-bit hex and back, record RGB 0–1 (or a vec3) alongside the final output and selected options.

How this works

Each channel is clamped to 0–1, multiplied by 255, and rounded to the nearest integer. 1 0.5 0 becomes #ff8000. Going back, each hex byte is divided by 255.

Ordinary HEX ↔ RGB pages ignore this. Pasting 0.2, 0.4, 0.8 into a 0–255 field gives a near-black color. That is the whole reason this page exists.

No linear-to-sRGB transfer is applied. If your engine is linear and your hex is sRGB, you still need a color-managed step this tool does not pretend to do.

Frequently asked questions

Inclusive 1.0?

Yes. 1.0 maps to 255.

Can I paste “vec3(0.2, 0.4, 0.8)”?

The three numbers are pulled out of the text.

Alpha?

Not on this page.