execute
Run arbitrary JavaScript against the Figma Plugin API inside the plugin to read or edit designs. Pass an async function body with figma and helpers in scope; return JSON-serialisable data.
Instructions
Run arbitrary JavaScript against the Figma Plugin API inside the plugin. The code is the body of an async function with figma and h (helpers: h.hex(hex)->Paint, h.rgb(hex)->RGB(A), h.node(id), h.ser(node, depth), h.loadFonts(textNode), h.findVariable(nameOrId)) in scope. return a JSON-serialisable value (nodes are auto-serialised). Use *Async APIs (dynamic-page).
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"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Async function body, e.g. `const n = await figma.getNodeByIdAsync('1:2'); return n.name;` | |
| file | No | Target file (fileKey, id or name). Defaults to the most recently active file. | |
| timeoutMs | No |