CSS Variables Generator

Build a :root block of CSS custom properties and copy it.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

This tool turns your design tokens — colours, spacing, radii, fonts — into a clean block of CSS custom properties (CSS variables) ready to drop into any stylesheet. Add name-and-value pairs and the generator normalises each name to valid syntax and outputs a :root block, so you can centralise your theme and reference it everywhere.

How it works

You enter name-and-value pairs. The tool normalises each name to valid custom-property syntax: it ensures a leading --, replaces illegal characters with hyphens, and trims stray dashes. Empty values default to initial. The cleaned pairs are wrapped in a :root { ... } block, which makes the variables global to the whole document. You then reference any of them with the var() function, optionally with a fallback.

Example

Three tokens become:

:root {
  --color-primary: #6366f1;
  --spacing: 16px;
  --radius: 8px;
}

Use them anywhere with var():

.button {
  background: var(--color-primary);
  padding: var(--spacing);
  border-radius: var(--radius);
}

Everything runs in your browser — nothing is uploaded.

Everything runs in your browser — nothing is uploaded.

Ad placeholder (rectangle)