Turn code into beautiful shareable images with syntax highlighting and gradient backgrounds
Preview
Code Snippet to PNG turns a block of code into a shareable, polished image — ready for LinkedIn, a slide deck, a blog post, or a README. Syntax highlighting is powered by Shiki using full TextMate grammars. Export at 2x pixel density for crisp rendering on retina displays.
Supported themes: GitHub Dark · Tokyo Night · Dracula · Nord · One Dark Pro · Catppuccin Mocha · Solarized Dark · Rose Pine
Supported languages (30+): JavaScript · TypeScript · Python · Rust · Go · Java · C · C++ · C# · Bash · SQL · HTML · CSS · JSON · YAML · TOML · Markdown · Ruby · PHP · Swift · Kotlin · Scala · Dart · Elixir · Haskell · Lua · R · MATLAB · Dockerfile · GraphQL
The rendering pipeline has three stages:
shiki/bundle/web) runs a full TextMate grammar tokenizer, the same engine used by VS Code. It assigns semantic token types to each character, which is why the highlighting is accurate rather than approximate regex-based coloring.html-to-image walks the DOM node, inlines all computed styles, and renders it to an HTML5 canvas via foreignObject. The canvas is then exported as a PNG data URL at window.devicePixelRatio * 2 (typically 4x on a retina screen), then downloaded via a temporary <a> element.The 2x export size matters: at 1x, text on a retina display looks blurry when the image is displayed at native size. At 2x, a 600px-wide code window exports at 1200px — sharp on every device.
Technical communication happens increasingly in visual-first formats. A LinkedIn post with a code block rendered in plain text gets skipped. The same code as a well-styled image gets engagement. Same content, different packaging.
The problem with most online “code to image” tools is that they send your code to a server. That’s a non-starter for anything proprietary. This tool renders entirely in the browser — Shiki is a browser-compatible library, html-to-image is pure client-side canvas work. Your code never leaves the tab.
The choice of Shiki specifically matters. Many “code screenshot” tools use Prism.js or highlight.js, which are regex-based tokenizers tuned for speed. Shiki uses VS Code’s actual TextMate grammar engine, which produces accurate highlighting even for complex nested syntax — template literals, JSX expressions, Rust lifetimes, Python type annotations. The output looks like your actual editor, not like a generic code block.
Dark themes dominate code screenshots because they read better when embedded in dark-mode social feeds and slides. If you’re embedding into a light-mode document, the GitHub Dark theme offers the least jarring contrast differential.
For informational purposes only. Not financial, medical, or legal advice. You are solely responsible for how you use these tools.