CSS Theme Token Builder

Edit light and dark theme-variable rows and export the matching CSS custom properties.

On-device No sign-up Free to use

Build theme tokens controls

?

1–50 objects with name, light and dark. Names omit --. Values: opaque HEX colors or nonnegative px/rem/em/% lengths; both modes need the same value type. No declarations, URLs or expressions.

Processed in your browser. Your inputs stay on this device.

Showing an example. Change the fields, then use build theme tokens to update it.

Result

Showing an example.

Define a white light surface and a dark surface, with system preference as a fallback.

:root, :root[data-theme="light"] { --surface: #FFFFFF; }
:root[data-theme="dark"] { --surface: #111111; }
With system preference enabled, the dark value also applies when no explicit theme is set and the device requests dark colors.

Loading the tool. Your result will appear here.

https://usefreetools.net/css-theme-token-builder · 20 November 2026

Was this helpful?

How to use CSS Theme Token Builder

  1. Edit the Light and dark CSS variables rows or the JSON array. Give each token a unique name without -- and valid light and dark values.
  2. Choose whether a device’s dark preference should apply when the root has neither data-theme="light" nor data-theme="dark". An explicit light or dark choice takes priority.
  3. Select Build theme tokens and inspect the CSS, then copy or download the CSS and JSON.
  4. Use the custom properties in actual declarations, such as background: var(--surface). Implement any theme switch separately and check contrast in both themes.

Example: CSS Theme Token Builder

Define a white light surface and a dark surface, with system preference as a fallback.

You add
Theme tokens as JSON: [{"name":"surface","light":"#ffffff","dark":"#111111"}]; Use system dark preference unless an explicit theme is set: true
You get
:root, :root[data-theme="light"] { --surface: #FFFFFF; } :root[data-theme="dark"] { --surface: #111111; } With system preference enabled, the dark value also applies when no explicit theme is set and the device requests dark colors.

Options

Names and value types
Use 1 to 50 unique lowercase names beginning with a letter, followed by letters, digits or hyphens, up to 48 characters. Omit --. Both values for a token must be colors or both lengths, though their length units can differ.
Theme selection
The exported root defaults to light values. data-theme="light" and data-theme="dark" on the root select an explicit mode. With the system option on, dark device preference applies only when neither explicit value is present.
Using the values
An exported variable must be referenced by a CSS property to affect a page. var(--token, fallback) handles a missing variable in a browser with custom-property support; it does not add a working theme toggle.

Supported inputs and limits

  • Only documented value types are accepted.
  • No arbitrary declarations, URLs, expressions or injected selectors.
  • Generated tokens do not check contrast, implement a theme switcher or provide a browser compatibility guarantee.
  • One to 50 tokens in at most 20,000 JSON characters.
  • Names are lowercase and at most 48 characters.
More details

Light and dark values must share a type: opaque HEX colors or nonnegative lengths up to 10,000 px or 100 rem/em/%, with at most four decimal places.

Native rows supplement the advanced JSON input.

Theme tokens are generated values; they do not automatically establish readable contrast on a complete site.

Where your input is processed

This tool does not upload your inputs. See the limits for anything saved on your device.

A token needs a consumer

Use the exported custom properties in actual declarations such as background: var(--surface). Merely defining a variable does not style an element. Check all text and control boundaries in both themes, since two valid color values can still have poor contrast. Unsupported declarations and URLs are refused rather than copied into the generated stylesheet.

Questions about CSS Theme Token Builder

Does this add a theme switch to my site?

No. It exports declarations and selectors. Your site must implement the switch and retain its state if needed.

Can I paste a whole CSS declaration as a value?

No. Enter a supported value only. Braces, declaration separators and other injection forms are refused.

Do the dark values pass contrast?

They are your chosen values. Check each foreground/background pair separately.

What does the CSS fallback support?

var(--token, fallback) supplies a value when the property is missing in a browser that supports CSS custom properties. For older browsers, add a separate literal declaration before the var() declaration.

Page updated · Project managed by Tony Hines · Report a problem with CSS Theme Token Builder