Figma Plugin
Export local variables from an open Figma file as variables.json.
The Primitree export plugin calls Figma's local variables Plugin API in the open file. It writes variables.json in the REST response shape that primitree build reads.
Install (development)
From the monorepo:
pnpm --filter primitree-plugin buildIn Figma desktop:
- Plugins → Development → Import plugin from manifest
- Select
apps/figma-plugin/dist/manifest.json - Run Primitree export on a file with variables
Exported data
The plugin calls:
figma.variables.getLocalVariableCollectionsAsync()
figma.variables.getLocalVariablesAsync()The JSON has this top-level shape:
{
"status": 200,
"error": false,
"meta": {
"variableCollections": { ... },
"variables": { ... }
}
}Aliases retain { "type": "VARIABLE_ALIAS", "id": "..." }. The export keeps modes, scopes, code syntax, and the extended collection fields that the Plugin API returns.
After export
primitree build variables.json
primitree check design-tokens
git add variables.json design-tokens/The playground builds and zips the same file in the browser.
Options
- Skip variables hidden from publishing omits hidden variables and visible variables whose aliases depend on an omitted variable
Library variables
The plugin exports data from getLocalVariableCollectionsAsync() and getLocalVariablesAsync(). It does not fetch remote library collections.
Monorepo layout
| Path | Role |
|---|---|
apps/figma-plugin | Figma UI + sandbox code |
packages/plugin-export | Private REST-shaped serializer |
Figma MCP vs Primitree MCP
See Figma MCP and Primitree for the live-file and repository data paths.