Design-Tool Variables to Code Tokens

Design-Tool Variables to Code Tokens

A design tool's variables map closely onto token groups and themes. Here is the export path, the causes of drift, and the single-source pattern for keeping the two in sync.

A design tool's variable collections and modes map almost one-to-one onto token groups and themes, and aliased variables mirror the semantic-references-primitive chain. The reliable way to keep them synced is to pick one source of truth, export it to a structured token file that feeds the build, and treat the other side as generated and read-only. A bidirectional round-trip with no single source is what produces values nobody trusts. This article covers the mapping, the export path, the concrete causes of drift, and the reconciliation pattern it recommends.

Variables are tokens in a design tool

A design tool's variables are not a separate concept from code tokens — they are the same tokens, authored in a different editor. When a design tool exposes variable collections and modes, those structures line up closely with the parts of a token system an engineer already knows.

A collection groups related variables the way a token group gathers related names. A mode inside that collection is the design-tool form of a theme: a light mode and a dark mode are two value sets over the same variable names, exactly as a light theme and a dark theme are two value sets over the same semantic tokens. When a designer switches a frame from light to dark and the colors resolve, that is the same value-set swap the code side performs at build or runtime.

Aliasing carries over just as directly. A variable can reference another variable of the same type instead of holding a raw value, which is the design-tool version of the reference chain — a semantic token pointing at a primitive. text/default aliasing neutral/900 in the tool is the same relationship as a semantic token referencing a primitive in code. Because the two models line up this cleanly, the sync problem is not one of translation between foreign shapes. It is one of deciding which editor holds the truth and keeping the other honest.

The export path

The variables do not reach the build by being retyped. They reach it by being exported to a structured token file — increasingly a file shaped by the Design Tokens Community Group (DTCG) format, which gives primitives, semantic aliases, and composite tokens an interchange shape that a build tool can consume (Design Tokens Format Module 2025.10, as of November 2026). That file is the handoff artifact: the design tool writes it, and the build reads it.

The export can run through the design tool's built-in export, through a plugin, or through an API. In Figma, for example, the Variables view can export variable modes to a JSON file on the Professional, Education, Organization, Government, and Enterprise plans, while the Variables REST API is limited to the Enterprise plan (as of November 2026). Tools in this space — the design tool's own variable export, and plugins such as Tokens Studio and its peers — are named here as market reality, not as an endorsement. In outline, the exporter, built-in or plugin, walks the collections and modes, resolves or preserves the aliases, and emits a token file that the build pipeline turns into CSS custom properties, platform constants, or whatever the consumers need. The build itself owns that last conversion; the point here is only that the export produces the file the build starts from.

The decision that actually matters is direction. Either the design tool is the source of truth and code is generated from the export, or code is the source of truth and the design tool is populated from it. One direction has to win, because the export is only trustworthy when it flows one way. The example below shows an exported token file in DTCG shape, generated from design-tool variables.

json
{
  "color": {
    "neutral": {
      "900": {
        "$type": "color",
        "$value": { "colorSpace": "srgb", "components": [0.071, 0.082, 0.11], "hex": "#12151c" }
      }
    },
    "text": {
      "default": { "$type": "color", "$value": "{color.neutral.900}" }
    }
  }
}

Here the design tool authored both the primitive and the alias, and the export preserved the reference. The build resolves {color.neutral.900} when it compiles the file. Nobody hand-copied a hex into code, which is the property that keeps the two sides from disagreeing.

Why design and code drift

Drift is what happens when both sides can be edited and neither is clearly generated. It can accumulate quietly until a value in the design differs from the value shipping in production and no one can say which is correct.

Three causes are covered here. A manual edit on either side — a designer nudging a variable in the tool, or an engineer tweaking a compiled value in code — puts the two out of step the moment it lands. A partial export syncs some tokens and leaves others behind, so a subset silently reverts to older values. And a naming mismatch, where the design tool calls a token one thing and the code calls it another, breaks the correspondence so the export cannot line the two up at all.

Drift causeWhat it looks likeReconciliation
Manual edit on the generated sideCode value differs from the design value; next export would overwrite itMake the generated side read-only; route the change through the source
Partial exportA subset of tokens is stale while the rest updatedExport the whole set atomically, not per-token by hand
Naming mismatchThe same token has two names, so nothing lines upAgree one taxonomy; the article on token naming covers the rule

The deeper failure underneath all three is the bidirectional round-trip. When designers edit in the tool and engineers edit in code and both changes are supposed to flow back to the other, there is no answer to "which value is right" — only two editors each convinced they hold the truth. The round-trip feels collaborative and produces conflicting values nobody trusts.

The reconciliation pattern this article recommends is: pick one source, generate the other from it, and treat the generated side as read-only. If the design tool is the source, the token file and the compiled code are outputs — you never edit them by hand, and if you need a change you make it in the tool and re-export. If code is the source, the design tool's variables are populated from it and designers treat the tool as a mirror. Either choice works. What does not work is leaving both editable.

Keeping the sync honest

Choosing a source is the decision; a few habits keep the choice from eroding back into a round-trip.

Automate the export so the token file is generated on a trigger, not copied by a person. A hand-copied file can drift as soon as someone is in a hurry; a generated one removes the manual step that gets skipped. Wiring the export into the same place the build runs means the token file is regenerated from the source when the build runs, rather than kept as a snapshot someone forgot to refresh.

Validate the correspondence in both directions. Every token in code should trace back to an origin in the design source, and every token in the source should appear in the export — a token that exists on one side and not the other is drift caught early instead of late. This check is cheap to run in the pipeline and turns a silent divergence into a failed build.

It is worth being clear about what this differs from. The reconciliation here is the variable-to-code sync mechanics: how the design tool's structures become the token file the build consumes, and how the two sides stay in step. It is a separate concern from collapsing the guideline document into tokens — that is about retiring a written spec in favor of the source, and it is a separate topic. This article covers only the sync pipeline between the design tool and the code.

And there is an honest limit. Tooling can carry the structure across — collections to groups, modes to themes, aliases to references — within each tool's documented limits (Figma's DTCG import, for example, accepts only some token types and units), but it cannot decide the taxonomy for you. A designer and an engineer still have to agree on what the tokens are named and how they are organized, and that agreement is human work, covered in the article on token naming. The export keeps a shared taxonomy in sync; it does not invent one. Get the source-of-truth direction right and automate the flow, and the two editors stop disagreeing — but only after the people using them have agreed on what the names mean.

Project Inquiry