Build a palette, export it straight into the syntax your codebase actually uses.
Color2Code turns a color palette into source code you can paste directly into your project. Instead of manually converting a hex value to the syntax your language or graphics library expects, pick your colors here and copy the exact line you need.
Most graphics APIs - OpenGL, GLSL shaders, glm, Unity's Color struct, Godot's Color class - represent color channels as floating-point values between 0.0 and 1.0, not the 0–255 integers used in web design (hex, CSS rgb()). This is because GPUs work in normalized floating-point color space internally. To convert, divide each channel by 255: a red value of 232 becomes 232 / 255 ≈ 0.910.
glm (OpenGL Mathematics) is a C++ header-only library that mirrors GLSL's vector and matrix types, commonly used in OpenGL and Vulkan projects. glm::vec3 is a 3-component float vector, frequently reused to represent an RGB color as three normalized floats, e.g. glm::vec3(0.910f, 0.722f, 0.294f).
Hex (#e8b84b) is the standard for CSS, design tools, and config files. RGB integers (0–255 per channel) are used in CSS rgb(), Python's PIL/Pillow, and most 2D APIs. Normalized floats (0.0–1.0 per channel) are used in shaders, OpenGL/Vulkan, and most game engines' color structs - including glm, GLSL, Unity, and Godot.
Does this upload my colors anywhere?
No. Everything runs in your browser and your palette is stored only in your own browser's local storage - nothing is sent to a server.
Can I use this for a game or app I'm shipping?
Yes, the output is just plain code - copy it into your own source file like you would any snippet.
Why is my glm::vec3 output different from a plain RGB tuple?
glm::vec3 uses normalized floats (0.0–1.0) with an f suffix per component, since that's what GLSL and OpenGL expect - not raw 0–255 integers.
Is more export formats planned?
The format list is easy to extend - if you need one that's missing, it's a quick addition.