Screenshot2Code (S2C) — OCR for Code Screenshots!
Published in
5 min readMay 5, 2023
In a nutshell: Use Screenshot2Code to convert code screenshots to text while preserving its format and steering clear of clipboard limitations!
Project repository: https://github.com/DragonX-AI/Screenshot2Code
Say you’re in any one of these scenarios…
- Your friend sends you a code screenshot message, but you want the code instead.
- The educational website you’re looking at uses code images instead of code.
- The reference website you’re using doesn’t allow for copying text to your clipboard.
- You’re taking notes for a programming class and you take a screenshot of code in a YouTube tutorial.
- The code you’re looking at is too long to copy and paste to your clipboard.
- The code you copied to your clipboard was overwritten by a more recent copy.
- The CS textbook you’re reading is a scanned PDF file that doesn’t allow copy-paste.
Whatever the case, there are many situations where you’ll end up with screenshots rather than source code! You have three options…
- Typing it out: Type out the entire content of the screenshot, taking a bunch of time.
- Using Conventional OCR: Convert code into text, and then fix the format errors.