Export Variables
Create a variables.json file for the Primitree build.
Primitree accepts a Variables REST API response, a bare meta object, or a plugin export with variables and collections.
Primitree export plugin
During local development, load the Primitree export plugin from this repository:
- Build the plugin with
pnpm --filter primitree-plugin build - In Figma, choose Plugins → Development → Import plugin from manifest
- Select
apps/figma-plugin/dist/manifest.json - Run Primitree export and download
variables.json
The plugin calls getLocalVariableCollectionsAsync() and getLocalVariablesAsync() in the open file. The CLI reads its output as a REST local variables response.
Other plugin exports
Primitree accepts these layouts:
{ meta: { variables, variableCollections } }{ variables, variableCollections }{ variables: [...], collections: [...] }
The normalizer accepts record maps or arrays for variables and collections. Published variables responses do not contain mode values and cannot feed the build.
Variables REST API
Figma limits the Variables REST API to Enterprise organizations. A local variables request needs file_variables:read and access to the file.
export FIGMA_TOKEN=figd_...
export FIGMA_FILE_KEY=AbCdEf...
primitree export --out variables.jsonRun a check before building:
primitree check variables.jsonKeep exports in version control
Commit variables.json when the repository needs to compare stable Figma IDs, names, types, and per-mode values across changes.
See Semantic diffing for how matching works.