TL;DR
Converting UI designs into code is a major bottleneck in front-end development. This paper introduces Figma2Code, a new benchmark and dataset that moves beyond image-only code generation by incorporating real-world Figma metadata and assets. While multimodal inputs drastically improve visual fidelity, the study reveals that current state-of-the-art models still struggle to balance pixel-perfect designs with responsive, maintainable code.
What Problem Does This Paper Address?
Historically, automated "design-to-code" systems have relied solely on screenshots of user interfaces. However, inferring complex UI details—like exact DOM hierarchies, hidden assets, and specific styling—from a flat image is incredibly difficult and often leads to subpar, hallucinated code.
In the real world, developers don't just stare at a JPEG; they use tools like Figma. These design files provide rich multimodal information, including structured metadata (JSON) and exportable assets (images, SVGs). The authors tackle the challenge of leveraging this multimodal data to generate production-ready UI code, bridging the gap between academic screenshot-to-code tasks and actual industry workflows.
Methods
The authors establish a comprehensive framework for multimodal UI generation:
- Data Pipeline: They built a rigorous curation pipeline by crawling the Figma community, applying heuristic and CLIP-based visual deduplication, and using human experts to filter and annotate the designs. Crucially, they refined the verbose Figma JSON metadata by pruning invisible nodes and extracting assets into local files.
- Evaluation Metrics: To evaluate the models without relying on a single "ground truth" codebase, they designed reference-free metrics across three dimensions:
- Visual Fidelity (Visual Embedding Similarity, Mean Absolute Error)
- Layout Responsiveness (Relative Unit Ratio, Absolute Positioning Ratio)
- Code Maintainability (Semantic Tag Ratio, Arbitrary Value Usage).
- F2CAgent: They introduce a ReAct-style agentic workflow. Instead of dumping raw JSON into an LLM, F2CAgent converts the design into a simplified Intermediate Representation (IR), generates a deterministic initial HTML draft via rules, and then uses an LLM "Critic" and "Refiner" to iteratively debug and improve the code.
Datasets
The paper introduces the Figma2Code dataset, the first real-world benchmark for multimodal design-to-code.
- Unlike existing datasets (like WebSight or Design2Code) that only provide images, Figma2Code includes paired design images, structured metadata (JSON), and localized assets.
- It consists of 3,055 total samples, partitioned into a training/auxiliary set of 2,842 samples and a highly curated, balanced benchmark test set of 213 high-quality cases. The dataset spans diverse platforms (mobile/desktop), complexities, and content categories.
Key Insights and Ideas
- The Metadata Double-Edged Sword: Feeding models Figma metadata massively boosts visual fidelity but introduces a new problem: "rigidity." Models tend to lazily map absolute coordinates and primitive styles directly from the JSON, resulting in code that looks right but breaks on different screen sizes (poor responsiveness).
- Proprietary vs. Open-Source Trade-offs: Proprietary models are unmatched at making the code look exactly like the design. However, open-source models actually write cleaner, more semantic, and responsive HTML/CSS, even though they fail to nail the exact visual look.
- Modality Synergy: Ablation studies show that visual and metadata signals are complementary. Removing style/image metadata tanks visual fidelity, while removing geometry/hierarchy metadata destroys layout responsiveness. The models need both to succeed.
Key Results
- Visual Fidelity: Top proprietary models achieved the highest semantic similarity (VES: 0.8405) and lowest pixel error (MAE: 0.1874).
- Code Quality: Open-source models generated the most maintainable and responsive code, boasting the lowest Absolute Positioning Ratio (APR: 1.42%) and highest Semantic Tag Ratio (STR: 35.76%). In contrast, top proprietary models relied heavily on hardcoded, arbitrary values (AVU: 37.72%).
- Agentic Workflow Success: The proposed
F2CAgentachieved a VES of 0.7990, significantly outperforming standard direct prompting (VES: 0.6801) while partially mitigating the structural rigidity caused by metadata-only prompting.
Limitations and Future Work
- Limitations: The benchmark standardizes the target output to Tailwind CSS. While practical and widely used, this limits the evaluation of other frameworks (like React or Flutter). Furthermore, the core finding remains a limitation of the field: current MLLMs fundamentally struggle to balance visual fidelity with engineering best practices.
- Future Work: The authors suggest exploring reinforcement learning (RL) to train agents that better balance these competing objectives (e.g., rewarding responsive layouts). They also propose investigating diffusion models to improve the efficiency of UI code generation and developing more robust agentic workflows to handle complex, multi-component interfaces.
Summary updated