Primitree

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 build

In Figma desktop:

  1. Plugins → Development → Import plugin from manifest
  2. Select apps/figma-plugin/dist/manifest.json
  3. 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

PathRole
apps/figma-pluginFigma UI + sandbox code
packages/plugin-exportPrivate REST-shaped serializer

Figma MCP vs Primitree MCP

See Figma MCP and Primitree for the live-file and repository data paths.