Code to Image Generator

Plain screenshots of an editor look messy, and plain-text code pasted into a post loses all its colour. Paste a snippet here and get a tidy syntax-highlighted PNG — every keyword, string and comment in its proper theme colour. Free, no account, and your code never leaves your browser.

Your code is highlighted and drawn locally in your browser — nothing is uploaded.

Preview

How it works

  1. Paste the code — the language is detected automatically, or pick it yourself.
  2. Pick a theme — GitHub Light, GitHub Dark, Dracula or Nord; the preview re-colours instantly.
  3. Copy or download the PNG — a 2× image that stays sharp in posts, slides and docs.

Specifications

Input Source code pasted as text, language auto-detected or picked by hand
Output PNG at 2× scale, copied to clipboard or downloaded
Highlighting Real token highlighting via highlight.js — keywords, strings, comments, numbers and more, each in theme colour
Languages 18 built in: TypeScript, JavaScript, Python, Java, C, C++, Go, Rust, PHP, Ruby, Bash, SQL, CSS, HTML/XML, JSON, YAML, Markdown, INI/TOML
Themes GitHub Light · GitHub Dark · Dracula · Nord — full token palettes
Rendering Entirely in your browser — your code is never uploaded
Cost Free, unlimited, no watermark, no account

Good to know

The snippet is tokenised locally by highlight.js and painted onto a canvas token by token, so the exported file carries the same colours as the preview. Honest edges:

  • Detection can guess wrong: short or mixed snippets sometimes land on the wrong language — the manual picker fixes it in one click.
  • Long lines, wide images: the canvas grows with your longest line; there is no word wrap, exactly like a real editor screenshot.
  • PNG only: the export is a raster image, not editable text or SVG — that is what makes it safe to paste anywhere.
  • Private by design: nothing about your snippet — not even its language — is sent to a server.

Frequently asked questions

Is the syntax highlighting real?

Yes. Your code is tokenised by highlight.js — keywords, strings, comments, numbers and function names are recognised as distinct token types — and each type is painted in its own theme colour on the exported PNG. The preview you see is the exact canvas that gets exported.

Which languages are supported?

TypeScript, JavaScript, Python, Java, C, C++, Go, Rust, PHP, Ruby, Bash, SQL, CSS, HTML/XML, JSON, YAML, Markdown and INI/TOML. Pick one from the list, or leave it on auto-detect and the tool works it out from the code.

Auto-detect picked the wrong language. What can I do?

Choose the language manually from the dropdown — a manual pick always wins over detection, and the image re-renders immediately.

What themes are included?

Four editor themes, each with its own full token palette: GitHub Light, GitHub Dark, Dracula and Nord. Switching themes re-colours every token, not just the background.

Is my code uploaded anywhere?

No. Highlighting and drawing happen in your browser with the Canvas API. Your snippets never leave the page — safe for code you would not paste into a random server.

Any size limits?

The image is as wide as your longest line and as tall as your line count, at 2× scale. Very long lines make very wide images, so trim or wrap extreme lines before sharing to social feeds.

More free tools

Mermaid to PNG · Markdown Table to Image · Tweet to Image · OG Image Generator · Image Compressor · Color Palette Generator