---
updatedAt: 2026-08-25T18:33:56.000Z
agentTools:
  projectIndex: https://vi.developers.datature.com/llms.txt
---

# Screenshot to HTML

Train a VLM to convert design mockups and screenshots into production-ready HTML and CSS using your design system tokens and component patterns.

![Website screenshot of an e-commerce storefront with product listings and navigation](https://storage.googleapis.com/datature-vi-landing/assets/datasets/screenshot-to-html.jpg)

Frontend development often starts with a design mockup. A designer creates the visual layout, and a developer translates it into HTML and CSS. That translation step is time-consuming, especially when the design uses a custom design system with specific tokens, spacing, and component conventions.

Datature Vi trains a model on your own design system. You pair screenshots of UI components with the corresponding HTML and CSS code, and the model learns to generate code that matches your conventions. New mockups go in, production-ready markup comes out.

This does not replace a frontend developer. It handles the mechanical translation from visual layout to code, freeing developers to focus on interactivity, state management, and business logic.

For an interactive overview of this application, visit the [screenshot to HTML use case](https://vi.datature.com/usecase/screenshot-to-html) on vi.datature.com.

***

## Common applications

<InfoTable headers={['Task', 'What the model does']}>
  <InfoRow cells={['Mockup to HTML/CSS', 'Converts design screenshots into semantic HTML and styled CSS']} />
  <InfoRow cells={['Design system adherence', 'Generates code using your specific tokens, spacing, and class names']} />
  <InfoRow cells={['Component extraction', 'Identifies UI components in a screenshot and generates code for each']} />
  <InfoRow cells={['Responsive scaffolding', 'Produces markup with responsive layout structure']} />
</InfoTable>

***

## Task type: freeform text

This use case uses the [freeform text](https://vi.developers.datature.com/docs/freeform-text) dataset type. Each training pair is a screenshot (image) and the corresponding HTML/CSS code (text annotation).

### Annotation structure

Each image annotation contains the HTML and CSS that faithfully reproduces the screenshot:

<CodeGroup>

```html Example annotation
<nav class="nav-bar">
  <a href="/" class="nav-logo">Aura Collective</a>
  <ul class="nav-links">
    <li><a href="/collections">Collections</a></li>
    <li><a href="/artisans">Artisans</a></li>
    <li><a href="/stories">Stories</a></li>
  </ul>
</nav>

<style>
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-4) var(--spacing-8);
  background: var(--color-surface);
}
.nav-links {
  display: flex;
  gap: var(--spacing-6);
  list-style: none;
}
</style>
```

</CodeGroup>

### System prompt

<CodeGroup>

```text System prompt
You are a frontend code generator. Given a screenshot of a UI component or page, produce semantic HTML and CSS that reproduces the layout. Use the following design system conventions:
- CSS custom properties for colors (--color-*), spacing (--spacing-*), and typography (--font-*)
- BEM-style class naming
- Flexbox or Grid for layout
- No inline styles

Output only the HTML and CSS. Do not include JavaScript.
```

</CodeGroup>

***

## Deploy and test

<CodeGroup>

```python Convert a screenshot to HTML
from vi.inference import ViModel

model = ViModel(
    run_id="your-run-id",
    secret_key=".your-secret-key.",
    organization_id="your-organization-id",
)

result, error = model(
    source="mockup_screenshot.png",
    user_prompt="Generate HTML and CSS for this UI.",
    generation_config={"temperature": 0.0, "do_sample": False}
)

if error is None:
    html_code = result.result
    with open("output.html", "w") as f:
        f.write(html_code)
    print("HTML written to output.html")
```

</CodeGroup>

***

## Training tips

**Use your own design system:** the model should generate code that follows your team's conventions, not generic HTML. Train on screenshots paired with code that uses your actual CSS variables, class names, and component structure.

**Start with components, not full pages:** train on individual components first (nav bars, cards, forms, footers). Full-page generation works better once the model understands your component vocabulary.

**Include multiple viewport sizes:** if you want responsive output, include screenshots at mobile, tablet, and desktop widths, each paired with the responsive code.

**Clean up training code:** the code in your annotations should be the code you want the model to generate. Remove dead CSS, commented-out blocks, and framework boilerplate from training examples.

***

## Next steps

<BentoGrid className="grid grid-cols-1 md:grid-cols-3 gap-6 my-8">
  <BentoCard title="Freeform Text" description="Dataset type reference for custom text annotation schemas." href="http://vi.developers.datature.com/docs/freeform-text" faIcon="fa-solid fa-file-lines" />

  <BentoCard title="Configure Generation" description="Temperature and sampling settings for consistent code output." href="http://vi.developers.datature.com/docs/configure-generation" faIcon="fa-solid fa-sliders" />

  <BentoCard title="Structured Data Extraction" description="Full guide to schema design and system prompts for structured output." href="http://vi.developers.datature.com/docs/structured-data-extraction" faIcon="fa-solid fa-code" />
</BentoGrid>