CSS Color Generator
Generate CSS custom properties and color snippets from any color.
About the CSS Color Generator
Generate CSS custom properties and color snippets from any color. Every value is computed locally with vanilla JavaScript — there is no server round-trip, no sign-up and no limit on how many times you use it.
How to use
Choose a color
Enter a HEX value or pick one visually.
Generate variables
CSS custom properties are produced automatically.
Review the snippet
See the color expressed as HEX, RGB and HSL variables.
Copy the code
Paste the :root block straight into your stylesheet.
Benefits
Drop-in variables
Get a ready-made :root block for your design tokens.
Multiple formats
HEX, RGB and HSL variables from one color.
Cleaner stylesheets
Reference one variable instead of repeating values.
Features & supported formats
Features
- CSS custom property output
- HEX, RGB and HSL variants
- Copy-ready :root snippet
- Live color preview
- One-tap copy
Supported formats
Accuracy & limitations
The custom properties generated here are valid CSS you can paste directly, but they are a starting point for a design system rather than the system itself.
- The generated custom properties are valid CSS and work in all current browsers. Very old browsers without custom-property support need a static fallback.
- HSL values in the snippet are rounded for readability, so they may render a fraction differently from the source HEX.
- The variables are a starting point, not a design system. Naming, theming and dark-mode variants are decisions you still need to make.
- No contrast checking is applied to the values produced.
Frequently asked questions
What is a CSS variable?
A custom property such as --brand: #3b82f6 that you reference with var(--brand) anywhere in your stylesheet.
Why store colors as variables?
Variables let you change a color in one place and update it everywhere, which is ideal for theming.
Can I use the RGB variable for opacity?
Yes. Storing channels as numbers lets you write rgb(var(--color-rgb) / 50%) for transparency.
Where do I paste the snippet?
Into a :root block near the top of your CSS so the variables are globally available.
Do CSS variables work everywhere?
They are supported in all modern browsers; only very old browsers need a fallback.
Further reading
Color in CSS
Every way CSS lets you write a color, when custom properties beat hard-coded values, and what the newer color functions change.
FundamentalsColor Models Explained
What each color model actually measures, where each one is the right choice, and why the same color has six different sets of numbers.