Figma Code Generation with Hopper MCP Server
This guide demonstrates how to automatically generate Hopper Design System code from Figma designs using AI coding assistants. We'll cover setup, workflow, and troubleshooting tips to help you convert designs into production-ready code.
Overview
The Hopper MCP Server integrates with Figma's MCP server to automatically generate production-ready code from your Figma designs. Simply provide a Figma frame URL, and AI assistants will analyze the design and generate JSX code using the correct Hopper components, design tokens, and best practices. This turns hours of manual work into minutes!
To get best results ensure your Figma design follows Hopper's Figma Conventions Guide for accurate component, icon, and token mapping during code generation.
Prerequisites
Before you begin, ensure you have:
- AI Coding Assistant (choose one):
- Claude Code (Recommended): Provides the best results for Figma-to-Hopper conversion
- GitHub Copilot + Claude Sonnet 4.5: Install both GitHub Copilot and GitHub Copilot Chat extensions in your Visual Studio Code. Make sure to select Claude Sonnet 4.5 as the AI model in the Copilot Chat settings.
- Other assistants: You can also use Codex, Cursor, or any other MCP-compatible AI assistants.
- Figma access: Access to the Figma file you want to convert
- MCP servers configured: Both Hopper and Figma MCP servers set up (see Setup)
Why Claude Code? Our testing shows that Claude Code produces the most consistent and accurate Hopper code from Figma designs. GitHub Copilot with Claude Sonnet 4.5 works well for simpler scenarios but tends to be slower. Codex has significantly slower performance and produces inconsistent results.
Setup
1. Configure MCP Servers
Create or update .mcp.json in the root of your project:
2. Authenticate Figma MCP Server
- Type
/mcpin Claude terminal to manage your MCP Servers and select figma - Select Authenticate
- Click Allow Access when prompted in your browser
- You should see: "Authentication successful. Connected to figma"
For detailed step-by-step instructions with screenshots, see the Figma MCP Server documentation.
3. Verify MCP Servers are Running
- Open Claude Code console
- Type in
/mcpand look for the status indicators - All three servers (Hopper, Figma, Chrome DevTools) should show as active/connected (green)
- If a server fails to start, check the console logs for error messages
Usage
The Hopper MCP server includes a specialized prompt (i.e. /generate_code_from_figma_design) optimized for Figma-to-Hopper conversion. This workflow provides comprehensive guidance and validation to generate production-ready code.
Steps to Generate Code
-
Get the Figma frame URL
- Open your Figma file
- Select the frame you want to convert.
- Right-click → "Copy link to selection"
- Example:
https://www.figma.com/design/abc123/MyFile?node-id=123-456
Frame size limitations: Large or complex Figma frames may exceed your AI Assistant's context window size limits and cause the generation to fail. If this happens, break down your design into smaller frames and convert them separately.
-
Prompt
- In your AI assistant's chat, write down the following prompt, replacing the URL with your Figma frame link:
/generate_code_from_figma_design [URL]Note for assistants without MCP prompt support: If your AI assistant doesn't support MCP prompts (the
/generate_code_from_figma_designcommand), you can copy the full prompt directly from the Hopper MCP Server source code and paste it into your assistant's chat, replacing the Figma URL placeholder with your actual design URL.
The AI will now complete the automated workflow, which typically takes a few minutes.
Understanding the Generation Process
The AI follows this workflow when you use the provided prompt:
- Extract design information from Figma
- Fetch Hopper guides (styles, layout, icons, Figma conventions)
- Create mappings:
- Design tokens → component prop values
- CSS values → token names
- Figma layers → Hopper components/icons
- Generate initial code
- Validate with Hopper's validation tool
- Refine until all validation errors are resolved
- Compare visually with original Figma design
This ensures the generated code is close to production-ready and follows all Hopper best practices.
Follow-up Prompts
You may find these additional prompts useful after code generation.
- Use "Chrome Dev Tools MCP server"'s "take_snapshot" tool to compare the generated code screenshot with the original Figma design, identify all visual differences, and fix them
- Run the Hopper validation tool on the generated code to ensure all errors are resolved
- Review the Figma layer names and ensure right components are used
- Validate that all images and icons are properly imported
Troubleshooting
The AI Stops or Gets Stuck
If the generation process stops before completion, use these prompts to get it back on track:
- Continue the work
- Finish the undone tasks
- Address all the remaining errors and make sure to have all QA tasks are done
Build and Runtime Errors
If you encounter build or runtime errors, try these prompts:
- Run TypeScript type checking on the generated code and ensure there are no type errors
- Use "Chrome Dev Tools MCP server" to check the browser console for any runtime errors and fix them
Best Practices
- Start with small frames: Test the workflow with simple designs before tackling complex layouts
- Review mappings: When the AI shows token/component mappings, verify they look correct before proceeding
- Check early, check often: Don't wait until the end to validate - the AI should validate after each major change
- Keep designs organized: Use clear, descriptive layer names in Figma for better component mapping
- Validate manually: Even with automatic validation, review the generated code for logic and best practices
Limitations
While Figma-to-Hopper code generation is powerful, be aware of these limitations:
- Complex interactions: Advanced animations or interactions may need manual implementation
- Custom logic: Business logic and data fetching must be added manually
- Edge cases: Unusual design patterns may require custom code
- Design quality: Output quality depends on how well the Figma design follows design system guidelines
Next Steps
After generating your code:
- Review the implementation: Check that it matches your requirements
- Add business logic: Implement data fetching, event handlers, and state management
- Test thoroughly: Verify functionality, accessibility, and responsiveness
- Integrate: Add the component to your application
- Iterate: Refine based on user feedback and testing