ScreenCoder: Advancing Visual-to-Code Generation for Front-End Automation via Modular Multimodal Agents

Paper · arXiv 2507.22827 · Published July 30, 2025
RL with Verifiable Rewards (RLVR)

Automating the transformation of user interface (UI) designs into front-end code holds significant promise for accelerating software development and democratizing design workflows. While multimodal large language models (MLLMs) can translate images to code, they often fail on complex UIs, struggling to unify visual perception, layout planning, and code synthesis within a single monolithic model, which leads to frequent perception and planning errors. To address this, we propose ScreenCoder, a modular multi-agent framework that decomposes the task into three interpretable stages: grounding, planning, and generation. By assigning these distinct responsibilities to specialized agents, our framework achieves significantly higher robustness and fidelity than end-to-end approaches. Furthermore, ScreenCoder serves as a scalable data engine, enabling us to generate highquality image-code pairs. We use this data to fine-tune open-source MLLM via a dual-stage pipeline of supervised fine-tuning and reinforcement learning, demonstrating substantial gains in its UI generation capabilities. Extensive experiments demonstrate that our approach achieves state-of-the-art performance in layout accuracy, structural coherence, and code correctness.

Introduction. Automating front-end engineering is a critical step toward efficient software development, and recent large language models (LLMs) have advanced the generation of code directly from text instructions (Qwen, 2025; Bolt, 2025). However, this text-based approach faces significant limitations. Generating detailed UIs requires verbose prompts to capture structure and styling, struggles to specify fine-grained visual design like spacing or alignment, and fundamentally deviates from practical design workflows that begin with visual sketches, not paragraphs of text. Relying solely on textual input is therefore sub-optimal for real-world deployment and often fails to capture the full visual intent.

To bridge this gap, multimodal large language models (MLLMs) offer the promise of directly interpreting UI design images and translating them into code (Yang et al., 2023). While conceptually appealing, our analysis reveals that current MLLMs struggle with this task as it requires a unified set of capabilities, visual understanding, structural layout planning, and domain-specific code synthesis, that they are not holistically designed for. Empirically, this leads to two recurring failure modes: (1) perception errors, where components are missed or misclassified, and (2) planning errors, where components are placed incorrectly or violate layout constraints.

To address these limitations, we propose ScreenCoder, a modular multi-agent framework that decomposes the UI-to-code task into three interpretable stages: grounding, planning, and generation. The grounding agent leverages a multimodal large language model to localize and semantically label key UI regions. The planning agent then constructs a hierarchical layout tree using domain knowledge of web layout systems. Finally, the generation agent produces HTML and CSS code via adaptive prompt-based synthesis, incorporating both layout context and optional user instructions to support interactive design. This decomposition introduces architectural modularity, enabling more robust component recognition, layout planning, and structured code generation than end-to-end black-box methods. Experiments show that our framework achieves state-of-the-art performance in layout fidelity, structural coherence, and generation quality.

Beyond inference, our framework acts as a scalable data engine. This is crucial because training on raw web data is often infeasible, as its length and noise from dependencies and scripts destabilize training and prevent models from learning the core visual-to-code mapping (Si et al., 2025). To address the challenge, we leverage ScreenCoder to create Screen-10K, a new large-scale training dataset of 10,000 high-quality image-code pairs, curated by filtering an initial crawl of 50,000 webpages. We use Screen-10K to significantly enhance open-source MLLM via a dual-stage supervised fine-tuning and reinforcement learning pipeline. Furthermore, to facilitate a more rigorous evaluation of modern models, we introduce ScreenBench, a challenging new benchmark composed of 1,000 high-quality, up-to-date websites that reflect contemporary web design. Our framework thus provides a practical path for both scalable dataset creation and robust model alignment. To sum up, our contributions are as follows:

• We conduct a systematic investigation into the limitations of existing MLLMs on UI-tocode tasks and propose a novel modular multi-agent framework that decomposes the complex UI-to-code generation task into three interpretable stages: grounding, planning, and generation, significantly outperforming existing end-to-end multimodal models in layout fidelity and structural coherence. • Leveraging our framework as a scalable data engine, we introduce Screen-10K, a new largescale dataset containing 10,000 high-quality image-code pairs, which addresses a critical bottleneck in the field by providing a substantial resource for training more capable UI-tocode generation models. • To facilitate more rigorous and relevant evaluation, we present ScreenBench, a new challenging benchmark of 1,000 diverse and contemporary web designs. ScreenBench provides a more accurate measure of model performance on real-world tasks compared to existing benchmarks.

Related work. 2.1 MULTIMODAL LARGE LANGUAGE MODELS Multimodal Large Language Models (MLLMs) integrate vision and text to enable joint reasoning. Early models like VisualGPT (Chen et al., 2022) and Frozen (Tsimpoukelli et al., 2021) pioneered this by using pre-trained LLMs to decode visual features. Architectural innovations, such as Flamingo’s (Alayrac et al., 2022) gated cross-attention and BLIP-2’s (Li et al., 2023) Q-Former, further improved vision-language alignment. Modern systems like Gemini 2.5 (Google, 2024) and GPT-4o (OpenAI, 2024) have dramatically scaled these capabilities, excelling at complex multimodal tasks and enabling applications like website generation from images (Zhu et al., 2023). However, despite their impressive general-purpose abilities, these models struggle with domain-specific structured generation, such as UI-to-code synthesis. This limitation stems from a lack of inductive biases for spatial layout and hierarchical planning, as well as a monolithic architecture that hinders the injection of task-specific knowledge.

Early visual-to-code methods used CNNs and LSTMs to translate UI screenshots into domainspecific languages (DSLs) (Beltramelli, 2018), which offered limited real-world applicability (Xu et al., 2021). Subsequent research shifted towards generating general-purpose HTML/CSS (Chen et al., 2018) and improving component recognition, layout understanding (Cizotto et al., 2023), interaction-awareness (Xiao et al., 2024), and multi-page generation (Wan et al., 2024). Alternative approaches have included OCR-based techniques (Nguyen & Csallner, 2015) and object detection for screen parsing (Wu et al., 2021). More recently, divide-and-conquer methods (Wan et al., 2025; Wu et al., 2025; Gui et al., 2025) have emerged, but often depend on heuristic-based segmentation. Despite these advances, prior works are often brittle, rely on synthetic data, and lack the interpretability needed to jointly model complex visual semantics, layouts, and coding patterns. In contrast, our approach introduces a modular multi-agent framework that decomposes the task into interpretable sub-tasks: grounding, planning, and generation. This allows for explicit reasoning and the integration of domain-specific priors. Our system also functions as a scalable data engine to train future MLLMs, addressing the scarcity of high-quality, realistic image-code datasets.

Method. To motivate our approach, we analyze why state-of-the-art multimodal large language models (MLLMs) struggle with the direct, end-to-end generation of code from UI screenshots. While models like GPT-4o exhibit powerful general visual reasoning, our analysis of their outputs on real-world webpages reveals two primary failure modes, as illustrated in Figure 2: perception failures and planning failures.

First, perception failures stem from the model’s inability to accurately interpret visual elements. This materializes in two ways: (1) element omission, where smaller or less salient components like icons and secondary text are completely missed, and (2) element distortion, where an element is recognized but its attributes (e.g., text content, color) are incorrect, or its type is misidentified (e.g., an input field rendered as static text). Second, planning failures involve the inability to organize perceived elements into a coherent spatial and hierarchical structure. Even if all components are identified, they are often assembled incorrectly, leading to (1) element misarrangement, where components are placed in the wrong positions, and (2) hierarchical incoherence, where the model produces a “flat” layout that fails to infer the nested, DOM-like structure essential for modern, responsive web design. This highlights a lack of inductive bias for fundamental front-end layout conventions.

Our analysis indicates these failures arise not from an intrinsic inability to perform any single subtask, but from the burden of a monolithic, end-to-end approach that overloads a single model with granular perception, complex spatial planning, and structured code synthesis simultaneously. This task also demands deep domain knowledge of front-end development, such as layout systems and component hierarchies, which general-purpose MLLMs lack. Inspired by agentic workflows that decompose complex problems, we hypothesize that separating these distinct challenges will yield more robust results. This insight directly motivates our modular, multi-agent framework. By explicitly decoupling the task into grounding (to address perception failures), planning (to address structural failures), and generation (to focus on code synthesis), we enable each agent to specialize. Crucially, this modularity allows us to inject specific domain knowledge at each stage, such as established layout conventions in the planning agent, thereby mitigating the failure modes inherent in a single, end-to-end process.

We propose a modular, multi-agent framework for UI-to-code generation that decomposes the complex task into three sequential agents: grounding, planning, and generation. This design is explicitly motivated by the failure modes identified in Section 2; each agent is specialized to address a distinct sub-problem, allowing the system to leverage both visual understanding and structured reasoning in a coordinated manner. The grounding agent targets perception errors by accurately identifying UI components. The planning agent tackles planning errors by constructing a coherent layout hierarchy. Finally, the generation agent translates this structured plan into high-fidelity code. Our overall framework is shown in Figure 3.

The grounding agent serves as the perceptual front-end of our framework, tasked with detecting and semantically labeling major structural components to overcome the perception errors (element omission and distortion) common in end-to-end models. This design choice, assigning explicit labels like sidebar, header, and navigation, is crucial for enabling interactive, language-driven To accomplish this, the agent employs a Multimodal Large Language Model (MLLM) queried with prompts such as “Where is the sidebar?” or “Locate the header area.” The MLLM returns a set of grounded regions as bounding boxes and their associated labels:

Discussion. Interactive Design and Human-in-the-Loop Feedback. One key strength of our modular pipeline is its potential to support interactive design iteration. Since each stage, grounding, planning, and generation, is disentangled, user feedback can be incorporated at different abstraction levels. For instance, designers can manually adjust the layout tree or re-prompt specific components without restarting the entire process. Future work may further enhance this interactivity by integrating real-time preview, editable intermediate representations, and dialogue-based refinement.

Scalability and the Cost-Quality Trade-Off. Our modular framework offers a flexible trade-off between computational cost and output quality via test-time scaling. Users can select smaller, faster models for quick, low-fidelity drafts or larger, more powerful models for high-fidelity, productionready code. While a high-quality generation takes tens of seconds, this is an acceptable trade-off for its intended use as a workflow accelerator where initial code quality is the priority. This versatility allows the system to be adapted for different stages of the development process. Future work can further enhance this flexibility. We envision a system where developers can interactively refine the output, dedicating more compute only to the specific components that require changes. This moves beyond a one-off generation and towards a more dynamic, resource-efficient, human-in-the-loop partnership.

Conclusion. We present ScreenCoder, a modular multi-agent framework for UI-to-code generation that addresses key limitations of end-to-end models, and also functions as a scalable data engine to improve MLLMs via dual-stage post-training with supervised fine-tuning and reinforcement learning. Experiments demonstrate state-of-the-art performance in visual fidelity and code correctness, offering a practical solution for front-end automation and a foundation for future research in multimodal program synthesis.

Lines of inquiry this paper opens 24

Research framings built by reading the notes related to this paper — the questions it feeds into.

How should design principles adapt for AI-generated interfaces? Can visual rendering-based rewards effectively improve code and layout quality? What prevents AI agents from achieving claimed real-world autonomy? What perception approach enables GUI agents to work most effectively? Can agents learn from feedback and experience to improve behavior? What conditions and architecture enable effective agent ecosystems? What mechanistic structures underlie the reasoning traces that language models produce? What makes AI failures visible and contestable to users? When does multi-agent coordination outperform scaling a single agent? Why does expressing understanding diverge from achieving genuine comprehension?