Scripts2026年4月1日·1 分钟阅读

Screenshot to Code — Convert Designs to Code

Screenshot to Code converts screenshots, mockups, and Figma designs into clean code using AI. 72.1K+ GitHub stars. HTML, React, Vue, Bootstrap. MIT.

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 17/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
Script
安装
Stage only
信任
信任等级:Established
入口
screenshot-to-code.md
安全暂存命令
npx -y tokrepo@latest install e8c64554-d3b8-402d-b5c7-74bce0b57159 --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

TL;DR
Converts screenshots and mockups into clean HTML, React, Vue, or Bootstrap code using AI vision models. Open-source, MIT license.
§01

What it is

Screenshot to Code is an open-source tool that converts screenshots, mockups, and Figma designs into clean, functional code. It uses AI vision models to interpret visual layouts and generate HTML, React, Vue, or Bootstrap code that reproduces the design.

The tool targets developers and designers who want to accelerate the design-to-code workflow. Instead of manually coding a layout from a mockup, upload a screenshot and get working code in seconds.

§02

How it saves time or tokens

Manually converting a design mockup to code takes hours of measuring spacing, matching colors, and writing responsive CSS. Screenshot to Code automates this translation, producing a working first draft that developers can refine.

The generated code uses standard HTML and CSS rather than proprietary components, making it easy for AI coding assistants to further modify and extend.

§03

How to use

  1. Clone and run the application:
git clone https://github.com/abi/screenshot-to-code.git
cd screenshot-to-code
pip install -r requirements.txt
cd frontend && npm install && npm run dev
  1. Open the web UI and upload a screenshot or paste a URL.
  1. Select the output format (HTML/CSS, React, Vue, Bootstrap).
  1. The AI analyzes the visual layout and generates code that reproduces the design.
  1. Copy the generated code and integrate it into your project.
§04

Example

<!-- Generated from a landing page screenshot -->
<section style='display: flex; flex-direction: column; align-items: center; padding: 4rem 2rem;'>
  <h1 style='font-size: 2.5rem; font-weight: 700; margin-bottom: 1rem;'>Build Faster with AI</h1>
  <p style='font-size: 1.2rem; color: #666; max-width: 600px; text-align: center;'>Convert any design into production-ready code in seconds.</p>
  <button style='margin-top: 2rem; padding: 0.75rem 2rem; background: #2563eb; color: white; border-radius: 8px; border: none;'>Get Started</button>
</section>
§05

Related on TokRepo

§06

Common pitfalls

  • Expecting pixel-perfect output. AI vision models approximate layouts. The generated code is a starting point, not a finished product. Plan for manual refinement of spacing, fonts, and responsive behavior.
  • Using low-resolution screenshots. Higher resolution inputs produce better results. Crop tightly to the area you want converted.
  • Not specifying the output framework. The default HTML output may not match your project stack. Select React or Vue if that is what your project uses.
  • Failing to review community discussions and changelogs before upgrading. Breaking changes in major versions can disrupt existing workflows. Pin versions in production and test upgrades in staging first.

常见问题

How accurate is the code generation?+

Screenshot to Code produces a reasonable approximation of the input design. Simple layouts with clear structure convert well. Complex designs with overlapping elements, custom fonts, or animations require manual adjustment after generation.

Which AI models does Screenshot to Code use?+

Screenshot to Code supports multiple vision-capable models including GPT-4o, Claude, and Gemini. The model interprets the visual layout and generates code. You need an API key for your chosen model provider.

Can it convert Figma designs directly?+

Screenshot to Code works with screenshots of Figma designs. For direct Figma integration, export your design as an image and upload it. Some workflows also support pasting Figma URLs for automatic screenshot capture.

What output formats are supported?+

Screenshot to Code generates HTML/CSS, React (JSX), Vue, and Bootstrap code. The output uses standard web technologies without proprietary dependencies, making it easy to integrate into any project.

Is Screenshot to Code free?+

The tool is open-source under the MIT license and free to self-host. You pay for the AI model API calls (OpenAI, Anthropic, or Google). A hosted version is also available for users who prefer not to run it locally.

引用来源 (3)
🙏

来源与感谢

abi/screenshot-to-code — 72,100+ GitHub stars

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产