TL;DR
DesignAsCode introduces a novel paradigm that treats graphic design generation as a programmatic synthesis task using executable HTML/CSS. By replacing flat images and rigid templates with a dynamic "Plan-Implement-Reflect" pipeline, it produces professional-grade graphic designs that are fully editable at the attribute level while maintaining exceptional visual fidelity.
What Problem Does This Paper Address?
Automating graphic design usually forces a compromise between two extremes. On one hand, Text-to-Image (T2I) diffusion models generate visually stunning but completely "flat" raster images—making it impossible to edit text typos, swap fonts, or adjust layouts. On the other hand, layout generation models predict structural bounding boxes but leave them as empty placeholders devoid of actual visual content.
Recent hybrid approaches attempt to bridge this gap by predicting layout slots and filling them with generated images. However, these methods typically rely on rigid, primitive representations (like basic JSON coordinates) and fixed schemas (e.g., a single foreground over a single background). Furthermore, because they operate in an open-loop, unidirectional fashion, they suffer from visual dissonance—such as blindly placing white text over a light background highlight, rendering the final text unreadable.
Methods
The core innovation of DesignAsCode is establishing HTML/CSS as the unified representation space for graphic design. This allows the system to natively support sophisticated styling attributes (e.g., backdrop filters, complex gradients, and blending modes) while leveraging the structural coding priors already present in large language models (LLMs).
The framework executes this via a three-stage Plan-Implement-Reflect pipeline:
- Semantic Planner: A lightweight LLM (Qwen3-8B) fine-tuned via knowledge distillation to act as a design strategist. Given a user prompt, it uses Chain-of-Thought (CoT) reasoning to output a structured plan detailing layout logic, element groupings, image layer prompts, and textual specifications.
- HTML Implementation: An implementation module takes the planner's output, retrieves or generates the required image assets, and passes them as URL references to a multimodal LLM (Composer) to synthesize the initial HTML/CSS code.
- Visual-Aware Reflection: To fix visual flaws that are invisible in raw code, this module acts as an automated "Art Director." It renders the HTML into an image, uses an image editing model to optimize the visual layout (e.g., adjusting contrast or fixing overlaps), and then uses a vision model (Refiner) to update the underlying HTML/CSS code to match the optimized reference image.
Datasets
The authors evaluated their framework on two distinct benchmarks:
- The Standard Benchmark (Crello): A dataset consisting of 546 sampled cases containing rich metadata (individual layers, font attributes, and layout specifications). This was used to train the Semantic Planner and evaluate standard design tasks.
- The Broad-Spectrum Benchmark (Broad): A newly introduced, more challenging benchmark containing 500 high-quality samples. It expands coverage to highly diverse, real-world categories with complex structural demands, such as menus, resumes, business timelines, and calendars.
Key Insights and Ideas
- Code as a Native Design Medium: HTML/CSS is inherently superior to rigid JSON structures for graphic design. It naturally handles responsive reflowing, complex layering, and advanced web typography, allowing models to generate organic, professional-grade visual effects.
- Closing the Loop with Pixels: Code generators cannot "see" their mistakes. By translating code back into pixels, optimizing it in the image domain, and using that image to guide code refinement, DesignAsCode successfully resolves text-background conflicts and layout collisions.
- Moving Beyond Slot-Filling: Instead of forcing designs into repetitive templates, the semantic planner dynamically constructs variable-depth element hierarchies based entirely on the content's semantics.
Key Results
DesignAsCode demonstrated substantial improvements over state-of-the-art baselines (including DeepSeek-R1, GPT-5, and OpenCOLE):
- Quantitative Performance: On the Crello benchmark, DesignAsCode achieved a clear lead in structural Validity (0.9521), Readability (0.0849), and CLIP Score (0.6287), while maintaining an alignment precision virtually indistinguishable from GPT-5.
- User Study: In an evaluation by 20 participants with graphic design experience, DesignAsCode consistently secured the best (lowest) average rank in both Structure Rationality (1.92) and Visual Aesthetics (2.03).
- Downstream Applications: Because the output is native code, the framework unlocks advanced capabilities like Layout Retargeting (automatically reflowing elements to fit new aspect ratios without pixel distortion) and Attribute-Level Editability (instantaneous global theme switching via CSS variables).
Limitations and Future Work
Despite its strong performance, the authors note a few areas for improvement:
- Inference Latency: The multi-step agentic workflow takes approximately 1 to 5 minutes per design, making it slower than single-pass T2I models (though highly acceptable for asynchronous or batch tasks).
- Modular vs. End-to-End: The current pipeline separates asset generation from code composition. A tightly-coupled end-to-end paradigm that co-generates pixel textures and CSS parameters simultaneously could boost speed and stylistic harmony.
- Ultra-High Information Density: Scaling to massive multi-page documents drastically increases HTML token length. Future work will explore design-specific compression or specialized "design tokens" to optimize efficiency.
Summary updated