Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abi/screenshot-to-code
Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
https://github.com/abi/screenshot-to-code
Last synced: 5 days ago
JSON representation
Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
- Host: GitHub
- URL: https://github.com/abi/screenshot-to-code
- Owner: abi
- License: mit
- Created: 2023-11-14T17:53:32.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-10T18:32:21.000Z (11 days ago)
- Last Synced: 2024-12-10T19:45:41.816Z (11 days ago)
- Language: Python
- Homepage: https://screenshottocode.com
- Size: 2.48 MB
- Stars: 65,223
- Watchers: 389
- Forks: 7,938
- Open Issues: 102
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-ai-api-projects - screenshot-to-code - commit/abi/screenshot-to-code?label=%20) | (AI Agent / Task)
- awesome-projects - screen shot to code
- awesome-ccamel - abi/screenshot-to-code - Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue) (Python)
- awesome-starts - abi/screenshot-to-code - Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue) (others)
- starred - abi/screenshot-to-code - Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue) (Python)
- Awesome-AITools - GitHub - to-code?style=social)| 免费,需要有GPT-4 Vision的授权| (精选文章 / GPT-LLMs应用)
- StarryDivineSky - abi/screenshot-to-code - 4 Vision 生成代码,使用 DALL-E 3 生成外观相似的图像。您现在还可以输入 URL 来克隆实时网站 (前端开发框架及项目 / 其他_文本生成、文本对话)
- awesome - abi/screenshot-to-code - Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue) (Python)
- awesome-agents - screenshot-to-code
- awesome-agents - screenshot-to-code
- AiTreasureBox - abi/screenshot-to-code - 12-20_65856_14](https://img.shields.io/github/stars/abi/screenshot-to-code.svg)|Drop in a screenshot and convert it to clean HTML/Tailwind/JS code| (Repos)
- awesome - abi/screenshot-to-code - Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue) (Python)
- awesome - abi/screenshot-to-code - Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue) (Python)
- awesome-ai-papers - [screenshot-to-code - ai/vanna)\]\[[NL2SQL_Handbook](https://github.com/HKUSTDial/NL2SQL_Handbook)\]\[[TAG-Bench](https://github.com/TAG-Research/TAG-Bench)\]\[[Spider2](https://github.com/xlang-ai/Spider2)\] (NLP / 3. Pretraining)
- awesome-ai-papers - [screenshot-to-code - ai/vanna)\]\[[NL2SQL_Handbook](https://github.com/HKUSTDial/NL2SQL_Handbook)\]\[[TAG-Bench](https://github.com/TAG-Research/TAG-Bench)\] (NLP / 3. Pretraining)
- stars - abi/screenshot-to-code - Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue) (Python)
- stars - abi/screenshot-to-code - Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue) (Python)
- awesome - abi/screenshot-to-code - Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue) (Python)
- awesome - abi/screenshot-to-code - Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue) (Python)
README
# screenshot-to-code
A simple tool to convert screenshots, mockups and Figma designs into clean, functional code using AI. **Now supporting Claude Sonnet 3.5 and GPT-4o!**
https://github.com/abi/screenshot-to-code/assets/23818/6cebadae-2fe3-4986-ac6a-8fb9db030045
Supported stacks:
- HTML + Tailwind
- HTML + CSS
- React + Tailwind
- Vue + Tailwind
- Bootstrap
- Ionic + Tailwind
- SVGSupported AI models:
- Claude Sonnet 3.5 - Best model!
- GPT-4o - also recommended!
- DALL-E 3 or Flux Schnell (using Replicate) for image generationSee the [Examples](#-examples) section below for more demos.
We also just added experimental support for taking a video/screen recording of a website in action and turning that into a functional prototype.
![google in app quick 3](https://github.com/abi/screenshot-to-code/assets/23818/8758ffa4-9483-4b9b-bb66-abd6d1594c33)
[Learn more about video here](https://github.com/abi/screenshot-to-code/wiki/Screen-Recording-to-Code).
[Follow me on Twitter for updates](https://twitter.com/_abi_).
## 🌍 Hosted Version
[Try it live on the hosted version (paid)](https://screenshottocode.com). If you're a large or medium enterprise (50+ employees), [book a meeting to explore custom enterprise plans](https://cal.com/abi-raja-wy2pfh/30min).
## 🛠 Getting Started
The app has a React/Vite frontend and a FastAPI backend.
Keys needed:
- [OpenAI API key with access to GPT-4](https://github.com/abi/screenshot-to-code/blob/main/Troubleshooting.md) or Anthropic key (optional)
- Both are recommended so you can compare results from both Claude and GPT4oIf you'd like to run the app with Ollama open source models (not recommended due to poor quality results), [follow this comment](https://github.com/abi/screenshot-to-code/issues/354#issuecomment-2435479853).
Run the backend (I use Poetry for package management - `pip install poetry` if you don't have it):
```bash
cd backend
echo "OPENAI_API_KEY=sk-your-key" > .env
echo "ANTHROPIC_API_KEY=your-key" > .env
poetry install
poetry shell
poetry run uvicorn main:app --reload --port 7001
```
You can also set up the keys using the settings dialog on the front-end (click the gear icon after loading the frontend).Run the frontend:
```bash
cd frontend
yarn
yarn dev
```Open http://localhost:5173 to use the app.
If you prefer to run the backend on a different port, update VITE_WS_BACKEND_URL in `frontend/.env.local`
For debugging purposes, if you don't want to waste GPT4-Vision credits, you can run the backend in mock mode (which streams a pre-recorded response):
```bash
MOCK=true poetry run uvicorn main:app --reload --port 7001
```## Docker
If you have Docker installed on your system, in the root directory, run:
```bash
echo "OPENAI_API_KEY=sk-your-key" > .env
docker-compose up -d --build
```The app will be up and running at http://localhost:5173. Note that you can't develop the application with this setup as the file changes won't trigger a rebuild.
## 🙋♂️ FAQs
- **I'm running into an error when setting up the backend. How can I fix it?** [Try this](https://github.com/abi/screenshot-to-code/issues/3#issuecomment-1814777959). If that still doesn't work, open an issue.
- **How do I get an OpenAI API key?** See https://github.com/abi/screenshot-to-code/blob/main/Troubleshooting.md
- **How can I configure an OpenAI proxy?** - If you're not able to access the OpenAI API directly (due to e.g. country restrictions), you can try a VPN or you can configure the OpenAI base URL to use a proxy: Set OPENAI_BASE_URL in the `backend/.env` or directly in the UI in the settings dialog. Make sure the URL has "v1" in the path so it should look like this: `https://xxx.xxxxx.xxx/v1`
- **How can I update the backend host that my front-end connects to?** - Configure VITE_HTTP_BACKEND_URL and VITE_WS_BACKEND_URL in front/.env.local For example, set VITE_HTTP_BACKEND_URL=http://124.10.20.1:7001
- **Seeing UTF-8 errors when running the backend?** - On windows, open the .env file with notepad++, then go to Encoding and select UTF-8.
- **How can I provide feedback?** For feedback, feature requests and bug reports, open an issue or ping me on [Twitter](https://twitter.com/_abi_).## 📚 Examples
**NYTimes**
| Original | Replica |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| | |**Instagram page (with not Taylor Swift pics)**
https://github.com/abi/screenshot-to-code/assets/23818/503eb86a-356e-4dfc-926a-dabdb1ac7ba1
**Hacker News** but it gets the colors wrong at first so we nudge it
https://github.com/abi/screenshot-to-code/assets/23818/3fec0f77-44e8-4fb3-a769-ac7410315e5d