elefcode

Code to Image

Turn a code snippet into a shareable PNG for a README, slide, or social post.

Preview 0 × 0

Advertisement

Guide

About the Code to Image

Code pasted into a slide or a social post usually loses its formatting, its colours, or both. Exporting it as an image keeps it exactly as intended — and on platforms that show image previews, a screenshot of code reads far better than a wall of monospace text.

Paste a snippet, choose a theme, and download a PNG. Nothing is uploaded.

When an image is the right choice

Images are good for slides, social posts, blog headers and anywhere the code is being shown rather than used. They are the wrong choice when someone needs to copy the code — an image cannot be selected, searched, or read by a screen reader. In documentation and READMEs, a fenced code block is almost always better; save the image for the places that cannot render one.

How the rendering works

The snippet is tokenised with a syntax highlighter and drawn directly onto a canvas, rather than being screenshotted from the page. Because the preview and the exported file come from the same drawing code, what you download is exactly what you saw. The canvas is rendered at twice the display size, so the PNG stays sharp on high-density screens and when scaled up in a slide.

Themes and readability

Five editor themes are included — One Dark, Dracula, GitHub Dark, GitHub Light and Nord. For presentations, a light theme usually projects better than a dark one, since projectors wash out dark backgrounds. For social posts the reverse tends to be true. Font size matters more than theme: 16px or larger survives being viewed on a phone.

Keep the snippet short

The most common mistake is pasting too much. An image of forty lines is unreadable at the size most people will see it. Ten to fifteen lines showing one idea works far better — trim the imports, drop the error handling, and keep only the part you are actually talking about.

How to use it

  1. 1Paste your code and pick the language, or leave it on auto-detect.
  2. 2Choose a theme and adjust the font size and padding.
  3. 3Toggle the window bar, line numbers or background to taste.
  4. 4Download the PNG, or copy it straight to your clipboard.

Frequently asked questions

Is my code uploaded anywhere?

No. Highlighting and rendering both happen in your browser, and the PNG is produced locally from a canvas. Nothing is sent to a server.

What resolution is the exported image?

Twice the displayed size, so it stays sharp on retina screens and when enlarged. The pixel dimensions are shown above the preview.

Can I get a transparent background?

Yes. Turn off the Background toggle and the surrounding gradient is removed, leaving just the code window on transparency.

Why does Copy image not work in my browser?

Writing images to the clipboard is restricted in some browsers, particularly Firefox and older Safari. Use Download PNG instead — it works everywhere.

Which languages are supported?

Over 25, including JavaScript, TypeScript, JSX, Python, Go, Rust, Java, C, C++, C#, PHP, Ruby, Swift, Kotlin, SQL, Bash, JSON, YAML, HTML and CSS. Auto-detect handles anything else.

Related tools