Run Plugin API code
execute_codeRun JavaScript in the Figma plugin to perform tasks other tools don't cover, such as styles, variables, components, prototyping, and bulk edits, then return the result.
Instructions
Run JavaScript inside the Figma plugin (body of an async function; use await and return a value). Full Figma Plugin API via figma (document uses dynamic page loading: use figma.getNodeByIdAsync, await page.loadAsync() before reading other pages, await figma.loadFontAsync(font) before editing text).
Helpers in scope: getNode(id) (throws if missing), setProps(node, props) (same PROPS as update_nodes), serialize(node, depth=1, "full"|"outline"), parseColor("#hex") → {r,g,b,a}, loadFonts(textNode), log(...args).
The returned value is JSON-serialized (nodes become {id,name,type}); log() output is returned too. One undo step. Use it for anything the other tools do not cover: styles, variables, components, prototyping, plugin data, bulk edits.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>"
},
"name": "execute_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| timeoutMs | No |