How to Make a Shareable Screenshot of Your Code
November 2026 · 8 min read · By Macrae Myint
Code does not travel well as plain text in a social feed, a slide, or a chat app. Indentation collapses, fonts change, and a snippet that was clear in your editor becomes a wall of characters. A screenshot fixes that: the formatting is locked into an image, and you control the theme, the padding, and how large the type is. The ToolsForge Code Screenshot tool is built for that job. It runs in your browser and exports a PNG or JPG at twice the screen's pixel density.
What the tool actually produces
You paste a snippet, pick a language and a theme, optionally show macOS-style window chrome (the three traffic-light dots), set a background, and export. The image is rendered with html2canvas at 2× resolution, which is sharp enough for a retina blog header or a conference slide without a later trip through an image editor.
There are ten languages — JavaScript, TypeScript, Python, HTML, CSS, SQL, Bash, JSON, Go, and Rust — and five editor themes: vs-dark, a light theme, monokai, dracula, and a GitHub-dark style. Eight backgrounds are included, from gradients to solid slate or white. The highlighter is a lightweight, pattern-based engine: it colors comments, strings, and numbers in every language, and it colors a fixed keyword list for each language (for example, JavaScript's list covers the usual const, function, async, and similar words). It is not a compiler-grade parser. Unusual syntax, template languages, or keywords it does not know will not be colored the way your IDE colors them. For a short social or slide snippet, that difference is almost always invisible. For a syntax tutorial that depends on exact highlighting, take the screenshot from your editor instead.
Choices that change how the image reads
Length. Keep the snippet under about 30 lines. A long file becomes unreadable at the size people actually see a post or a slide. If you need to show a larger idea, split it into two images or crop to the function that matters.
Padding. The default is 48 pixels between the code window and the edge of the image. That is a good starting point when the background is a gradient, because the window looks like it is floating. On a solid white or slate background you can reduce it if you need the code itself to be larger in the frame.
Font size. Use 14–16px for X, LinkedIn, or a blog post that will be viewed up close. Bump to 18px or more for slides that will be seen from a few meters away. The default is 14px, which is comfortable on a phone feed and tight in a lecture hall.
Chrome. The traffic-light bar makes the image look like a window from a code editor, which is familiar in blog posts and social media. Turn it off when the chrome fights a tight slide layout, or when you want the snippet to look like a figure in a document rather than a desktop screenshot.
Export format. Prefer PNG. Text has hard edges, and JPG compression smears thin letterforms, especially on a gradient background. Use JPG only if a particular platform rejects PNG or you are hard against a file-size cap and have checked the result at 100% zoom.
Theme. Dark themes (vs-dark, monokai, dracula, GitHub) are the usual choice for social posts. The light theme is easier to print and often reads better in a PDF handout or a bright room. Pick one and stay consistent if you are making a series.
How to make the screenshot
- Open Code Screenshot. The editor loads with a short Fibonacci example so you can see the layout immediately.
- Paste your snippet, choose the language, and pick a theme and background.
- Adjust padding and font size so the code is readable at the size you will actually publish. Toggle the window chrome if you need a cleaner frame.
- Export as PNG (or JPG if you have a reason). The file downloads from this tab; the code is not uploaded.
Where the image will be seen
Think about the room, not only the editor preview. A dark theme looks polished on a phone and can wash out on a projector in a bright room; the light theme is usually easier to print and easier to read on a handout. If you are posting the image on a blog or in documentation, add real alt text that describes what the snippet does — search engines and screen readers cannot read the code out of a PNG. The image is for presentation; the repo or a gist is still the right place for code people should copy.
A note on secrets
A screenshot is easy to copy, crop, and repost. Do not paste API keys, tokens, connection strings, private keys, or customer data into the editor, even for a "quick internal" image. The tool does not send your snippet to a server, but the image you download will. Review the text one more time before you export, especially if you copied from a file that has environment variables nearby.
The same caution applies to comments and sample data. A realistic-looking email address, account ID, or hostname in a demo can still be someone's real value if you pasted from production. Use obvious placeholders.
Related: Code Screenshot.
Create a code screenshot
Syntax highlighting, editor themes, and a 2× PNG or JPG export. No account.
Open Code Screenshot →