Screenshot2Code (S2C) — OCR for Code Screenshots!

華士頓 Austin Hua
騰凱 Tokai
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…

  1. Your friend sends you a code screenshot message, but you want the code instead.
  2. The educational website you’re looking at uses code images instead of code.
  3. The reference website you’re using doesn’t allow for copying text to your clipboard.
  4. You’re taking notes for a programming class and you take a screenshot of code in a YouTube tutorial.
  5. The code you’re looking at is too long to copy and paste to your clipboard.
  6. The code you copied to your clipboard was overwritten by a more recent copy.
  7. 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…

  1. Typing it out: Type out the entire content of the screenshot, taking a bunch of time.
  2. Using Conventional OCR: Convert code into text, and then fix the format errors.

--

--

華士頓 Austin Hua
騰凱 Tokai

National Taiwan University CSIE. Professional focus in AI and the Chinese language.