Figma Plugins
Build Figma plugins to extend Figma’s functionality. Automate design tasks, create custom workflows, and integrate with external services using Claude Code.
Overview
Figma plugins let you add custom features to Figma. You can automate repetitive tasks, integrate with APIs, generate designs programmatically, and create custom tools for designers.
Prerequisites
Required
- Figma Desktop App - Download from figma.com/downloadsÂ
- Node.js - Download from nodejs.orgÂ
- Text Editor - VS Code recommended
Recommended
- Basic knowledge of JavaScript/TypeScript
- Familiarity with Figma interface
- Understanding of React (for UI plugins)
Setup
Create a new plugin
-
Open Figma Desktop App
-
Go to Plugins → Development → New Plugin
-
Choose a template:
- Empty - Blank plugin
- With UI - Plugin with HTML interface
- Run once - Simple one-time action
-
Choose save location
-
Figma generates starter files
Project Structure
my-plugin/
├── manifest.json # Plugin configuration
├── code.ts # Main plugin code (runs in sandbox)
├── ui.html # Plugin UI (optional)
└── package.json # DependenciesStart Claude Code
cd path/to/your/plugin
claudeDevelopment Workflow
Run your plugin
- In Figma: Plugins → Development → Your Plugin Name
- Plugin runs in current document
- Make changes to code
- Re-run plugin to see updates
Example prompts for Claude
"Create a plugin that generates a color palette from an image URL"
"Build a plugin that exports selected layers as React components"
"Create a plugin that auto-generates design system documentation"
"Build a plugin that imports data from CSV and creates text layers"
"Create a plugin that optimizes images by compressing them"
"Build a plugin that generates Lorem Ipsum text with custom parameters"Plugin Types
Run-once Plugins
Execute an action and close immediately.
// Example: Rename all layers
figma.currentPage.children.forEach(node => {
node.name = node.name.toUpperCase()
})
figma.closePlugin("✅ Renamed all layers")UI Plugins
Show an interface for user interaction.
// code.ts - Show UI
figma.showUI(__html__, { width: 400, height: 300 })
// Receive messages from UI
figma.ui.onmessage = msg => {
if (msg.type === 'create-shapes') {
// Create shapes based on UI input
}
}<!-- ui.html - Send messages to plugin -->
<button onclick="parent.postMessage({
pluginMessage: { type: 'create-shapes', count: 5 }
}, '*')">Create Shapes</button>Common Plugin Features
Access Selection
claude "get all selected layers and log their names"Create Shapes
claude "create 10 random rectangles with different colors"Modify Properties
claude "change all text layers to use 'Inter' font"Work with Colors
claude "extract all colors used in the current page"Generate Components
claude "create a button component with variants for primary, secondary, and disabled states"Export Assets
claude "export all images in the current frame as PNG files"Read Data
claude "read text from all text layers and create a list"Import Data
claude "create text layers from a JSON array of names"Advanced Features
External API Integration
claude "fetch quotes from an API and create text layers with the quotes"Image Processing
claude "apply filters to selected images"Auto Layout
claude "convert selected frames to auto layout"Component Management
claude "find all instances of a component and update their properties"Batch Operations
claude "resize all frames to 1920x1080"Building UI with React
Setup React
npm install react react-dom
npm install -D @types/react @types/react-domExample UI Plugin
claude "create a plugin UI using React that lets users generate a color palette"Figma API Highlights
Common APIs
// Selection
const selection = figma.currentPage.selection
// Create rectangle
const rect = figma.createRectangle()
rect.resize(100, 100)
rect.fills = [{type: 'SOLID', color: {r: 1, g: 0, b: 0}}]
// Create text
const text = figma.createText()
await figma.loadFontAsync(text.fontName)
text.characters = "Hello World"
// Export
const bytes = await node.exportAsync({format: 'PNG'})Access Styles
claude "get all color styles in the document and list their hex values"Variables (Design Tokens)
claude "create variables for spacing tokens (4, 8, 16, 32, 64)"Testing
Run in Figma
Test in real Figma environment:
- Make changes to code
- Run plugin in Figma
- Check console for errors (
Ctrl+Opt+IorCtrl+Shift+I)
TypeScript
Use TypeScript for better error checking:
claude "convert my JavaScript plugin to TypeScript"Publishing
Prepare for Publishing
- Test thoroughly
- Add icon (manifest.json)
- Write clear description
- Create screenshots
- Set permissions
claude "help me prepare my plugin for publishing on Figma Community"Publish to Community
- In Figma: Plugins → Development → Publish Plugin
- Fill out plugin details
- Upload screenshots
- Submit for review
Update Published Plugin
- Make changes
- Update version in manifest.json
- Publish new version in Figma
Pro Tips
Always test your plugin on different file sizes. Large files can cause performance issues.
- Use TypeScript to catch errors early
- Keep plugin code lightweight for better performance
- Handle errors gracefully (files can be large or complex)
- Use async/await for font loading and exports
- Cache data when possible to reduce API calls
- Provide clear user feedback (loading states, success messages)
- Test with empty selections and edge cases
- Follow Figma’s plugin guidelines
Common Use Cases
Design System Tools
claude "create a plugin that generates all component variations from a design system spec"Content Generation
claude "build a plugin that generates realistic user profiles with avatars and names"Export Tools
claude "create a plugin that exports designs as HTML/CSS"Accessibility Checkers
claude "build a plugin that checks color contrast ratios"Data Visualization
claude "create a plugin that generates charts from CSV data"Icon Management
claude "build a plugin that imports icons from an icon library API"Example Plugin Ideas
- Color palette generator from images
- Lorem ipsum text generator
- Design system documentation generator
- CSV to Figma table converter
- Batch resize tool
- Component variant generator
- Export to React components
- Icon set importer
- Spell checker for text layers
- Layout grid generator
- Chart creator
- QR code generator
- Barcode generator
- Placeholder image generator
Debugging
Console Logging
console.log("Selection:", figma.currentPage.selection)Error Handling
claude "add try-catch error handling to my plugin code"Chrome DevTools
Open DevTools in Figma:
- Mac:
Cmd + Opt + I - Windows:
Ctrl + Shift + I
Resources
Security
Never expose API keys in plugin code. Use environment variables or ask users to input their own keys.
Next Steps
- Install Figma Desktop App
- Create a new plugin using Figma’s built-in generator
- Start Claude Code in your plugin directory
- Build your first plugin
- Test thoroughly in Figma
- Publish to Figma Community
Start building plugins that make design workflows faster and more powerful!