How to Create a Beautiful Code Screenshot: Complete Step-by-Step Tutorial
Table of Contents
Creating a beautiful code screenshot is a repeatable, learnable skill. Once you understand what each setting does and why, you can produce professional-quality code images in 30 seconds for any language, any context, and any platform.
This is a complete step-by-step tutorial covering every setting in the Ocelot Code Screenshot tool, what it affects, and how to choose it for different use cases.
Before You Start: Preparing Your Code Snippet
The quality of a code screenshot starts before you open the tool. A poorly formatted snippet produces a poorly formatted image no matter how good the theme is.
Step 1: Choose the right snippet. Ask: what is the one thing I want the reader to understand from this image? Extract only the code relevant to that idea — remove imports, boilerplate, test scaffolding, and anything else that is not the point.
Step 2: Format it properly. Run your code through a formatter if you have one (Prettier, Black, gofmt). If formatting by hand: consistent indentation (2 or 4 spaces, not mixed), no trailing whitespace, no lines over 80-90 characters if avoidable.
Step 3: Check line count. Aim for 5-20 lines. Under 5 lines often looks like too little to be worth a screenshot. Over 25 lines creates a tall image that is hard to absorb at a glance.
Step 1: Paste Your Code and Select the Language
Open the Ocelot Code Screenshot tool. Paste your code into the text area using Ctrl+V (Windows) or Cmd+V (Mac).
Before doing anything else: set the language correctly. This is the most common mistake — pasting Python code but leaving the language as JavaScript. The syntax highlighter uses language-specific grammar rules; wrong language means wrong colors.
Available languages: JavaScript, TypeScript, Python, HTML, CSS, JSON, SQL, Go, Rust, Java, C++, Bash, Ruby, PHP, Swift, Kotlin, YAML, XML, Markdown.
If your language is not in the list, try the closest match. JSON or YAML syntax for config files often highlights better than leaving it as plain text.
Step 2: Choose a Syntax Theme
The theme controls the color palette of the syntax highlighting and the code window background. Choose based on context:
- Social media (Twitter, LinkedIn): Atom One Dark or Dracula — vivid, high-contrast, visually distinctive
- Blog posts: GitHub Dark or VS Code Dark — professional, familiar to most developers
- Documentation with white background: GitHub Light or Stack Overflow Light
- Conference slides: VS Code Dark or Nord — authoritative and clean on projectors
- Portfolio or personal brand: Dracula or Monokai — distinctive, memorable
The preview updates immediately when you change the theme. Try two or three options before committing.
Sell Custom Apparel — We Handle Printing & Free ShippingStep 3: Set the Background Color
The background color is the color behind the code window — the "frame" that makes the window pop.
Click the color picker and choose a color. A few heuristics:
- Contrast with the code window: The code window has its own dark or light background. Your chosen background color needs to clearly contrast with it. A dark window on a dark background disappears.
- Complementary hues: If the code window is dark gray-blue (like GitHub Dark), a deep navy or purple background complements it. A warm maroon would clash.
- For dark themes: Try deep navy (#0d1a2e), charcoal (#1c1c2e), or dark teal (#0d2020). These create clean contrast without competing with the syntax colors.
- For light themes: Use a light neutral — soft gray (#f5f5f5), white (#ffffff), or very light blue (#f0f4ff).
Step 4: Adjust Font Size
The font size slider goes from 10px to 24px. The default (14px) works for most use cases. Adjust based on:
- Social media: 16-18px — images render smaller in feeds, larger text stays readable
- Documentation: 13-14px — readers will view at full size, smaller text fits more code
- Conference slides: 16-20px — even at a high-DPI export, slides often display projected at lower effective resolution
- Long snippets: Go smaller (12-13px) to keep the image height manageable
- Short snippets (under 8 lines): Go larger (16-18px) to fill the image proportionally
The current font size shows as a number next to the slider. The preview updates live.
Step 5: Export and Use the PNG
When the preview looks right, click Export PNG. The image downloads immediately — no loading screen, no email confirmation, no "generating..." wait. It renders and downloads in under a second.
The exported file:
- PNG format — universally compatible
- 2x pixel density — sharp on retina screens and in print
- White background (for the area outside the code window)
- No watermark, no branding overlay
Common destinations for the exported PNG:
- Drag into a tweet or LinkedIn post
- Upload to a blog post image slot
- Insert into a slide deck
- Commit to a repository and reference in a README
- Email as an attachment
Try It Free — No Signup Required
Runs 100% in your browser. No data is collected, stored, or sent anywhere.
Open Free Code Screenshot ToolFrequently Asked Questions
How long does it take to create a code screenshot?
Under a minute once you know the settings. The first time takes longer as you explore theme and background options. After a few screenshots you will have a preferred combination and the process takes 20-30 seconds.
Can I undo changes if I make a mistake?
The code text area supports standard undo (Ctrl+Z / Cmd+Z). Theme, background, and font size selections can be changed at any time — the preview updates immediately. Nothing is permanent until you click export.
What if my code has long lines that extend beyond the window?
Long lines create a horizontal scrollbar in the preview. In the exported PNG, the code window expands to accommodate the full line width. If this creates an unusually wide image, consider wrapping long lines or reducing font size.
Can I batch-export multiple code screenshots?
Not automatically. The tool is designed for one snippet at a time. For batch exports, paste each snippet individually, configure, and export. With practice, a single export takes under 30 seconds.

