Color · Made a little simpler

Palette to CSS Variables

Turn a list of HEX, RGB, HSL or named colors into numbered CSS custom properties. Preview the swatches, choose a prefix and download a local stylesheet.

Free to useNo account neededProcessed on your device
Your workspaceProcessed on your device
#336699
#993366
#669933

Add this tool to your website

Paste this code into your page to add the tool and a visible ToolMellow credit link.

HTML embed code
Preview embed

Palette to CSS Variables: how to use it

  1. Paste one color per line, keeping the order you want for the variables.
  2. Choose a prefix starting with a letter and inspect the generated :root declarations.
  3. Copy the CSS or download the stylesheet, then reference a variable using var().

Limits and notes

Accepts up to 64 sRGB colors. Blank lines are ignored. The prefix supports 1 to 40 ASCII letters, digits and hyphens, starting with a letter. CSS functions that depend on document context are unsupported.

How your privacy works →

Palette to CSS Variables: common questions

What happens to duplicate colors?

The exporter keeps each entry in its original position. Two matching colors can have different numbered variables.

Does it preserve decimal opacity?

Yes. Translucent values are written as RGBA, which keeps the parsed opacity. HEX swatch labels round alpha to a byte.

Guides