Developer Tools
Code to Image (Beautiful Code Screenshots)
Turn code snippets into beautiful images for Twitter, LinkedIn, slides and docs — syntax highlighting, themes, window chrome and gradient backgrounds. Download PNG or copy to clipboard.
How to use
- 1Paste your code and pick the language.
- 2Choose a theme, background and title.
- 3Download a 2× PNG or copy the image to your clipboard.
Frequently asked questions
Which languages are highlighted?
JavaScript/TypeScript, Python, HTML/XML, CSS, JSON, SQL, Bash, Go, Java/C#/C++ and Rust.
Is my code uploaded?
No — the image is drawn in your browser.
What size is the image?
Exported at 2× for sharp results on high-resolution screens and social media.
A small hand-written highlighter, not a bundled library
Rather than shipping a heavyweight library like Shiki or Prism, the tool runs its own compact line-by-line tokenizer that recognizes keywords, strings, comments, numbers, function calls and type names per language — with dedicated handling for HTML tags/attributes, CSS selectors/properties, and block comments that span multiple lines. It covers JavaScript/TypeScript, Python, HTML/XML, CSS, JSON, SQL, Bash, Go, Java/C#/C++ and Rust. It's not a full parser, so unusual syntax (nested template literals, exotic regex literals) can occasionally mis-color a token — an acceptable trade-off for a tool whose output is a picture, not compiled code.
Worked example: the default snippet, rendered
The tool opens with a small TypeScript debounce() function, the Night theme, an Ocean gradient background, the title "debounce.ts", and line numbers on. Every keyword (const, function, return) is tinted separately from string literals, comments and the function name itself, then the whole thing is drawn onto a <canvas> with rounded window-chrome dots and a drop shadow — no DOM screenshot step involved.
Why canvas instead of a DOM screenshot
Tools like html2canvas re-render your actual DOM, which means fonts, scrollbars and sub-pixel spacing can come out slightly different from what you see on screen. Drawing directly to a <canvas> with explicit font metrics sidesteps that — the preview you edit and the file you download are produced by the exact same draw() routine, just scaled 2× for the final export so text stays crisp on retina displays and when shared to Twitter or LinkedIn.
Copy to clipboard isn't available everywhere
The Copy image button only appears when the browser exposes the ClipboardItem API, which some browsers (older Firefox, in particular) don't support for images. When it's missing, Download PNG (2×) is the fallback — it always works, since it just triggers a canvas.toBlob() download rather than relying on clipboard permissions.
Window chrome and the title bar are cosmetic, not functional
The rounded red/yellow/green dots and title bar at the top of the image are drawn purely for visual framing — they mimic a macOS window purely because that convention reads instantly as 'this is a code editor' to anyone scrolling past it on social media, not because the tool actually runs or executes anything resembling a window manager. The title text itself is just a label you set, commonly a filename like debounce.ts, but it accepts any string, so it's equally reasonable to title a snippet with a function name, a one-line description, or nothing at all by leaving it blank. Line numbers toggle independently of the chrome and theme, and because they're drawn as part of the same canvas pass as the code, turning them off shifts the whole code block left rather than leaving a gap — useful when a snippet is already short enough that line numbers would just be visual noise.
Related tools
- Online HTML, CSS & JS Editor (Live Preview)
Write HTML, CSS and JavaScript and see the result instantly — live preview, console, templates, shareable links and one-click HTML download. Like CodePen, with nothing to sign up for.
- Code Beautifier (HTML, CSS, JavaScript)
Beautify messy or minified HTML, CSS and JavaScript into clean, consistently indented code you can read and edit.
- JSON Formatter & Validator
Format, beautify, validate and minify JSON — with clear line and column error messages and optional key sorting.
- XML Formatter & Validator
Pretty-print and validate XML with readable indentation, or minify it — errors point to the exact line and column.
- QR Code Scanner & Safety Preview
Scan a QR code from an image or your camera — and preview where it leads before you open it, with warnings for suspicious links.
- Image to Text (OCR)
Copy text out of photos, screenshots and scanned images — in English and 100+ languages — with OCR that runs in your browser.