TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/open-pencil/open-pencil/llms.txt
Use this file to discover all available pages before exploring further.
eval command executes JavaScript code with access to the Figma plugin API (FigmaAPI). This provides programmatic access to all tools and operations.
Usage
Arguments
Path to the
.fig fileOptions
JavaScript code to execute
Read code from stdin instead of
--code flagWrite changes back to the input file
Write changes to a different file
Output result as JSON
Suppress output
Examples
Create a rectangle
Query nodes
Read code from stdin
Modify multiple nodes
FigmaAPI access
Thefigma object provides access to the Figma plugin API:
figma.currentPage- Current pagefigma.root- Document rootfigma.createRectangle()- Create shapesfigma.createText()- Create textfigma.createFrame()- Create framesfigma.createComponent()- Create componentsnode.findAll(predicate)- Search nodesnode.remove()- Delete nodes- All other FigmaAPI methods
Return values
The last expression orreturn statement is output:
toJSON() method are automatically serialized.
Writing changes
By default,eval does not modify the input file. Use --write or --output to persist changes:
--write- Overwrite the input file--output path.fig- Write to a different file
Use cases
- Batch updates to design tokens
- Automated refactoring
- Custom linting rules
- Data-driven design generation
- Integration with CI/CD pipelines
See also
- FigmaAPI reference - Complete API documentation
- Tools reference - Available tools
- MCP server - Alternative for AI coding tools