Code Screenshot Generator

Turn code snippets into beautiful shareable images

Overview

Code snapshot turns a code snippet into a styled PNG with a window frame, syntax highlighting and a themed background. Paste your code, check the preview, then choose Download PNG or Copy image. It is built on ray.so and suits blog posts, READMEs, social posts and slides where hand-cropped screenshots look inconsistent. It is free, needs no sign-up and adds no watermark. The page opens with a nine-line TypeScript sample in the Candy theme; the first click in the editor selects it, so a paste replaces it in one step.

Language and file name

The language is detected automatically from the first 4,000 characters; the Language field shows what was found, for example "Auto: Python". Detection covers TypeScript, TSX, JSX, JavaScript, JSON, HTML, CSS, SCSS, Vue, Python, Java, Kotlin, Swift, C, C++, C#, Go, Rust, PHP, Ruby, SQL, shell, YAML, TOML, Markdown, diff, Dockerfile, Lua and Dart. For a short snippet or any other language, open the field and pick one of the 200+ languages (or Plain text for no colours); a manual choice stays until you switch back to Auto.

Some themes show a file name in the window title. It is derived from the language (main.py, index.tsx, main.rs) or you can type your own in File name (up to 60 characters). A typed name also names the download: my-hook.ts saves as my-hook.png, otherwise the file is <language>-snapshot.png. Themes without a title bar, such as Vercel, show no file name.

Image size

The PNG is exactly what the preview shows, and its size does not depend on your screen. The code window is as wide as the longest line, from 44 to 100 characters; longer lines wrap inside the window. Padding adds the themed background around it (0 to 128 px, default 48 px). The size under the buttons, such as "1,344 × 788 px", is what you will get.

Image scale is 1x, 2x (default) or 4x. Browsers cap a canvas at about 16 million pixels and 16,384 px on one side, so a tall snippet is exported at a lower scale than you chose; the size under the buttons already shows the reduced size. Fonts are not bundled: the image uses your device's monospace font, so the same snippet looks slightly different on a Mac and on Windows.

Limits

A short snippet exports in about a second; a long one can take several seconds, up to about 15 on a busy or slow device, and a note appears above 150 lines. To keep the page responsive, a snippet of more than 400 lines or 20,000 characters, or a line longer than 3,000 characters, is not exported: the page says so under the buttons, and the preview shows only the beginning. Split a long file into several images.

Copy image is shown only in browsers that can put an image on the clipboard (current Chrome, Edge and Safari, and Firefox 127 or newer). Everywhere else use Download PNG.

The editor is a plain text field, so Tab moves to the next control instead of indenting. Indent in your own editor before pasting.

Code that snapshots well

  • 10–40 lines
  • Fewer than 80 characters per line
  • Focused on a single function or key fragment
  • Irrelevant comments and blank lines removed

What can go wrong

  • A wrong guess in Auto: pick the language by hand
  • Lines over 100 characters wrap in the image
  • No font is bundled, so glyphs come from your device and differ between a Mac and Windows
  • Transparent background flattened by some platforms
  • Zero padding removes the themed background

Keeping sensitive code safe

Rendering and export happen entirely in the browser; no code is sent to any server. Even so, replace real API keys and passwords with placeholders (like YOUR_API_KEY) before taking the snapshot. Published images are indexed by search engines and cannot be easily revoked.