Tools / Code to Image

Code to Image.

Turn a code snippet into a syntax-highlighted PNG or SVG with a window frame, for slides, docs and social posts.

Runs in your browser

2× keeps the text sharp on high-density screens and in slides.

Ctrl/⌘ + Enter to run · Ctrl/⌘ + Shift + C to copy the result

Result
PNG
SVG
Details

About Code to Image

Code to Image renders a snippet as a clean, syntax-highlighted picture, the kind you see in conference slides, blog headers, README files and posts on social networks where code blocks are not supported. Paste the code, pick the language or let the tool detect it, choose a theme, and download a PNG for sharing or an SVG that stays sharp at any size and keeps the text selectable in vector editors. Sixteen languages are highlighted, including TypeScript, JavaScript, PHP, Python, Go, Rust, Swift, Kotlin, Java, SQL, Bash, JSON, YAML, CSS and HTML/XML, using three themes modelled on GitHub Dark, GitHub Light and Monokai. Options add line numbers, macOS-style window controls, a window title such as the file name, a coloured frame around the window and a 1×, 2× or 3× PNG scale. For example, an eight-line retry helper in TypeScript at 2× gives an image about 1900 pixels wide that stays crisp on a projector. Typical mistakes: pasting a 200-line file (keep images to the 10–30 lines that make your point; nobody reads more in a screenshot), sharing code with API keys or internal hostnames in it, and relying on images where readers need to copy the code; link to a gist or repository as well. Tabs are expanded to four spaces. The text uses your system's monospace font, and both the highlighting and the rendering happen in your browser, so the snippet is never uploaded.

How to Use

  1. Paste your code and choose the language, or leave it on auto-detect.
  2. Pick a theme and toggle line numbers, window controls, title and frame colour.
  3. Download the PNG or the SVG.

Frequently Asked Questions

Is this like Carbon or ray.so?

It produces the same kind of framed, highlighted snippet image, but everything runs locally in your browser and you can also download an SVG.

Why does auto-detect pick the wrong language?

Short snippets are ambiguous; a few lines can be valid JavaScript, TypeScript and Java at once. Choose the language explicitly for the best colours.

Which font is used?

Your system's monospace font (SF Mono or Menlo on macOS, Consolas on Windows, DejaVu Sans Mono on Linux), so no web fonts are downloaded.

Is there a size limit?

Up to 500 lines and 300 columns per line, which is far more than fits legibly in an image.

Related Tools