Back to Blog
·5 min read

CodeSnap: AI-Powered Code Screenshots with GPT-4o-mini Explain

How I built a code screenshot tool with CodeMirror editor, 4 presentation themes, and an AI explain feature using GPT-4o-mini for instant code understanding.

MA
Manas AgrawalAI Product Builder & Full Stack Developer

The Problem

Every time I wanted to share code on X (Twitter) or in a blog post, I'd waste 15-20 minutes formatting it. Open an editor, paste the code, take a screenshot, crop it, adjust the font size. Repeat for every code block.

There had to be a better way.

What CodeSnap Does

CodeSnap is a live code editor that generates beautiful, presentation-ready screenshots in one click.

Live Code Editor Powered by CodeMirror, the same editor used in VS Code. Full syntax highlighting, line numbers, and proper indentation.

4 Presentation Themes Dark, Light, Nord, and Monokai. These cover 99% of what developers actually want for code presentation.

One-Click Export Click "Download" and get a 2x resolution PNG ready for social media, presentations, or documentation.

AI Explain Feature This is the killer feature. Click "Explain" and GPT-4o-mini generates a clear, line-by-line explanation of what the code does. Perfect for: - Understanding unfamiliar code - Creating tutorial content - Preparing code walkthroughs

Tech Stack

  • **Next.js** + TypeScript
  • **CodeMirror** for the editor
  • **highlight.js** for syntax themes
  • **html-to-image** for screenshot export
  • **GPT-4o-mini** via OpenAI API for code explanation

The AI Explain Integration

The explain feature uses GPT-4o-mini because it's fast and cheap. For a code explanation, you don't need GPT-4. The prompt engineering is straightforward — send the code with a system instruction to explain line-by-line in plain English.

The response streams in real-time, so users see the explanation building as the AI generates it.

What's Next

I want to add: - Custom themes (user-uploaded color schemes) - PDF export - Code diff visualization - Collaborative editing

Deployed on Vercel

CodeSnap is live at codesnap-eta.vercel.app. Try it — paste some code, pick a theme, download the screenshot.

All Articles
Next.jsAICodeMirrorGPT-4o-miniDeveloper Tools