Palette to CSS Variables

Palette to CSS Variables converts a list of HEX colors into `:root { --name-1: #color; ... }` CSS custom properties, useful for bringing a design palette directly into code.

CSS output
:root {
  --color-1: #3366cc;
  --color-2: #ff6600;
  --color-3: #22c55e;
}

How it works

  1. 1Enter the colors, one HEX code per line.
  2. 2Optionally customize the variable prefix (default 'color').
  3. 3The CSS output is generated instantly.
  4. 4Use 'Copy' to paste the result directly into a CSS file.

Frequently asked questions

How are the variable names numbered?+

They're numbered incrementally in the order you entered them, as --prefix-1, --prefix-2; if you want meaningful names (e.g. --color-primary) you'll need to edit the output manually.

Can I enter colors in RGB or HSL format?+

No, only HEX format (like #fff, #ffffff) is currently supported; convert other formats to HEX first (you can use the HSL Converter or HEX ↔ RGB Converter tools).

What happens if I enter an invalid color?+

If any line in the list isn't a valid HEX code, the tool marks the entire output as invalid, it doesn't produce a partial/broken CSS block.

Can I use these variables with Tailwind or CSS-in-JS?+

Yes, they're standard CSS custom properties; they can be used in any CSS/CSS-in-JS environment via `var(--color-1)` syntax or referenced from Tailwind config.

Embed on your site

Size
480 × 360px
<iframe
  src="https://toolsqube.com/en/color/palette-to-css-variables/embed"
  width="480" height="360"
  style="border:0;border-radius:14px"
  title="Palette to CSS Variables · ToolsQube"
  loading="lazy">
</iframe>

Want to go deeper on this topic: Color and Design Guide →

Command Palette

Search for a command to run…