← Back to Skills Marketplace
wangjipeng977

Ai Image To Code

by 王继鹏 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
53
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install skill-factory-image-to-code
Description
Use when (1) user provides a UI screenshot or image and asks to convert it into HTML, CSS, or component code. (2) user says "turn this into code", "rebuild t...
README (SKILL.md)

AI Image to Code

Use when (1) user provides a UI screenshot or image and asks to convert it into HTML, CSS, or component code. (2) user says "turn this into code", "rebuild this UI", "code this design", or "generate HTML from screenshot". (3) user pastes an image and says "write the React component for this".

Core Position

This skill solves the specific problem of: a visual UI mockup needs to become actual runnable frontend code — not just a description, but a working implementation.

This skill IS NOT:

  • An image generation tool — it converts existing images to code, not creates images
  • A design tool — it interprets and codes a design, not create the design
  • A backend integration tool — it outputs HTML/CSS/JS, not server code

This skill IS activated ONLY when: image (screenshot/mockup) + code generation intent are both present.

Modes

/ai-image-to-code

Default mode. Converts a UI image into a complete HTML/CSS implementation.

When to use: User provides a screenshot and wants a working HTML page that resembles it.

/ai-image-to-code/react

Outputs a React functional component using Tailwind CSS.

When to use: User explicitly asks for React or a component, not a plain HTML page.

/ai-image-to-code/describe

Provides a detailed text description of the layout without writing code.

When to use: User only wants to understand the layout before committing to code generation.

Execution Steps

Step 1 — Analyze the Image

  1. Receive image (pasted, file attachment, or URL)
  2. Use vision model to inspect the image and extract:
    • Layout structure (header, sidebar, main content, footer)
    • Color palette (primary, secondary, background, text, accent)
    • Typography (headings, body, labels — size and weight hierarchy)
    • Spacing system (padding, margins, gaps)
    • Component types (buttons, inputs, cards, lists, navigation)
    • Visual hierarchy (what stands out, what recedes)
  3. If the image is complex (>10 distinct UI sections), focus on the main content area

Step 2 — Plan the Code Structure

Image Content Recommended Output
Landing page Single HTML with embedded CSS
Dashboard HTML + CSS grid layout
Mobile app screen Mobile-first responsive HTML
Form / login page Semantic HTML form with proper inputs
Card / list UI Component-based HTML with classes
Chart / data visualization SVG or canvas-based rendering

Step 3 — Generate Code

HTML/CSS output (default):

\x3C!DOCTYPE html>
\x3Chtml lang="en">
\x3Chead>
  \x3Cmeta charset="UTF-8">
  \x3Cmeta name="viewport" content="width=device-width, initial-scale=1.0">
  \x3Ctitle>UI\x3C/title>
  \x3Cstyle>
    /* Extracted colors, typography, spacing from image */
  \x3C/style>
\x3C/head>
\x3Cbody>
  \x3C!-- Structure matching the image layout -->
\x3C/body>
\x3C/html>

React + Tailwind (react mode):

export function UICard() {
  return (
    \x3Cdiv className="p-6 bg-white rounded-xl shadow-sm">
      {/* Component matching image */}
    \x3C/div>
  );
}

Step 4 — Validate

  • Key layout sections (header, main, sidebar) are present
  • Colors are within ±10% of the original image (subjective match)
  • No invented content — placeholder text is generic ("Card title", not specific brand names)
  • HTML is valid (proper tag nesting, no unclosed tags)

Mandatory Rules

Do not

  • Do not invent brand names, specific product names, or proprietary text not visible in the image
  • Do not claim the output is pixel-perfect — it is an interpretation
  • Do not generate backend code, JavaScript logic, or API calls
  • Do not reproduce copyrighted UI elements (logos, icons) — use generic equivalents

Do

  • Use placeholder text that fits the context (e.g., "Search..." for a search bar)
  • Preserve the visual hierarchy (primary > secondary > tertiary)
  • Use realistic placeholder data for images (e.g., via placeholder.com or picsum)
  • State explicitly: "This is an approximation; fine-tune colors and spacing as needed"

Quality Bar

A good output:

  • All major layout regions are present and positioned correctly
  • Color palette is recognizably derived from the image
  • Typography hierarchy matches (heading size > body size)
  • Code is valid, runnable HTML/CSS without external dependencies beyond a CDN

A bad output:

  • Layout is scrambled or missing major sections
  • Output includes broken or unclosed HTML tags
  • Fabricated text content not appropriate to the UI context
  • Output requires non-free dependencies or local asset files

Good vs. Bad Examples

Scenario Bad Output Good Output
E-commerce product card Generic lorem ipsum text "Price: $49.99 — Add to Cart" contextually appropriate
Dark mode UI Ignores dark theme Uses dark background, light text, correct contrast
Mobile screenshot Desktop-only output max-width: 375px container, mobile-first
Complex dashboard One undifferentiated div Grid layout with sidebar, header, main panels

References

  • references/ — Color extraction heuristics, layout structure patterns, Tailwind class mapping guide
Usage Guidance
Reasonable to install if you want an agent to turn UI screenshots into approximate frontend code. Review generated code before using it, and avoid feeding screenshots that contain private data, copyrighted branding, or non-UI images unless you intend the agent to analyze them.
Capability Assessment
Purpose & Capability
The artifacts consistently describe converting user-provided UI screenshots or mockups into HTML/CSS, React/Tailwind components, or a layout description, and explicitly exclude backend code, API calls, image generation, and proprietary content invention.
Instruction Scope
The activation wording is somewhat broad around screenshots/images plus code-generation intent, but it remains tied to UI-to-code work and includes limits on output behavior.
Install Mechanism
Installation is a normal ClawHub install or manual copy into the OpenClaw skills directory; no automatic installer, package execution, privileged setup, or hidden install behavior is present.
Credentials
The skill only needs the image the user provides and normal code-generation context; it does not request credentials, local profile/session stores, broad filesystem access, or external service authority.
Persistence & Privilege
No background workers, startup hooks, durable state, privilege escalation, destructive commands, or mutation of user data are instructed by the skill.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install skill-factory-image-to-code
  3. After installation, invoke the skill by name or use /skill-factory-image-to-code
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release
Metadata
Slug skill-factory-image-to-code
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Ai Image To Code?

Use when (1) user provides a UI screenshot or image and asks to convert it into HTML, CSS, or component code. (2) user says "turn this into code", "rebuild t... It is an AI Agent Skill for Claude Code / OpenClaw, with 53 downloads so far.

How do I install Ai Image To Code?

Run "/install skill-factory-image-to-code" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Ai Image To Code free?

Yes, Ai Image To Code is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Ai Image To Code support?

Ai Image To Code is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Ai Image To Code?

It is built and maintained by 王继鹏 (@wangjipeng977); the current version is v1.0.0.

💬 Comments