Skip to main content

Variables

Get Variables

List all local variables and variable collections in a Figma file.

Returns all local variables and their collections defined in a file. This is essential for design token extraction and sync workflows.

GET https://api.figma.com/v1/files/:file_key/variables/local

Authentication

Requires a valid access token with file_content:read scope. Pass via X-Figma-Token header (personal access token) or Authorization: Bearer header (OAuth).

Parameters

Path parameters

The key of the file to retrieve variables from.

Example Request

curl -X GET "https://api.figma.com/v1/files/YOUR_FILE_KEY/variables/local" \
  -H "X-Figma-Token: YOUR_TOKEN"

Response

{
  "meta": {
    "variables": {
      "VariableID:1:1": {
        "id": "VariableID:1:1",
        "name": "brand/primary",
        "key": "abc123",
        "variableCollectionId": "VariableCollectionId:1:0",
        "resolvedType": "COLOR",
        "valuesByMode": {
          "1:0": { "r": 0.635, "g": 0.349, "b": 1.0, "a": 1.0 },
          "1:1": { "r": 0.4, "g": 0.2, "b": 0.8, "a": 1.0 }
        },
        "scopes": ["ALL_SCOPES"],
        "description": "Primary brand color"
      }
    },
    "variableCollections": {
      "VariableCollectionId:1:0": {
        "id": "VariableCollectionId:1:0",
        "name": "Brand Colors",
        "key": "def456",
        "modes": [
          { "modeId": "1:0", "name": "Light" },
          { "modeId": "1:1", "name": "Dark" }
        ],
        "defaultModeId": "1:0",
        "variableIds": ["VariableID:1:1"]
      }
    }
  }
}

Response Fields

FieldTypeDescription
meta.variablesobjectMap of variable IDs to variable objects
meta.variables[id].idstringUnique variable identifier
meta.variables[id].namestringVariable name (uses / for grouping)
meta.variables[id].keystringStable key for cross-file references
meta.variables[id].variableCollectionIdstringThe collection this variable belongs to
meta.variables[id].resolvedTypestringCOLOR, FLOAT, STRING, or BOOLEAN
meta.variables[id].valuesByModeobjectMap of mode IDs to values
meta.variableCollectionsobjectMap of collection IDs to collection objects
meta.variableCollections[id].modesarrayList of modes (e.g., Light, Dark)

Variables support multiple modes (for example, light and dark themes). Use valuesByMode to access the value for each mode. The defaultModeId tells you which mode is the default.