Code to Image Converter
WM-128Paste a snippet, pick the language and theme, and get a PNG of your code on a window-style card with a gradient behind it. It is made for slides, docs and posts where a text block would lose its formatting.
Runs in your browser. Nothing is uploaded.
Code and style
Code image
Open an image, drop or paste one here, or press Sample.
How to use it
- Paste your code and choose its language.
- Pick a theme, a background and the padding around the card.
- Set the font size, window title, line numbers and wrap width.
- Press Download PNG, or Copy image to paste it into a slide or a post.
How the colors are chosen
The highlighter reads the code with simple lexical rules: comments, strings, numbers, keywords, literals such as true and null, function calls and property names each get a color from the theme. It knows JavaScript, TypeScript, Python, SQL, JSON, CSS, HTML, Go, Java, C#, C and C++, and shell scripts. It does not parse the code, so unusual syntax such as regular expressions may stay in the plain color. Apart from tabs, which become spaces, and blank lines at the end, which are dropped, the code is drawn exactly as pasted.
Getting a sharp image
The default export scale is 2x: the card is laid out at the size you see and saved with twice the pixels on each side, so text stays crisp on high-density screens and projectors. Choose 3x for print, or 1x for a small file. Long lines make the card wider; pick a wrap width of 80 or 100 characters to keep it narrow for a post. Very large exports are scaled down to stay under 16.7 million pixels.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Paste some code to turn into an image. | The code box is empty or holds only spaces and blank lines. | Paste or type the code you want to show. |
The code has 2,500 lines. The limit is 2,000 lines. | The image would be too tall to draw. The number shown is your line count. | Paste the part of the file you want to show, or split it into several images. |
Questions people ask
How do I take a screenshot of code?
You do not need a screenshot. Paste the code here and the tool draws it at high resolution with syntax colors, which is sharper than a screen capture and has no editor clutter. Download the PNG or copy it straight to the clipboard.
Which programming languages are supported?
JavaScript, TypeScript, Python, SQL, JSON, CSS, HTML, Go, Java, C#, C and C++, and Bash shell scripts, plus a plain text mode without colors. For a language that is not on the list, plain text keeps the code readable without guessing at colors.
Can I make the background transparent?
Yes. Choose Transparent as the background. The PNG then holds only the card with its rounded corners and no shadow, which suits slides and documents that already have their own background color.
What font is used for the code?
Your system monospace font, such as SF Mono or Menlo on a Mac and Consolas on Windows. No font is downloaded, so the image appears at once and nothing leaves your device, but the same code can look slightly different on another computer.
Is my code uploaded anywhere?
No. The code is colored and drawn on a canvas in this browser tab, and the PNG is created on your device. A share link keeps the code after the # sign, a part of the address that browsers do not send to the server.
Why is the code image so wide?
The card grows to fit the longest line. Set Wrap long lines at to 80 or 100 characters and longer lines continue on the next row, without a new line number. You can also lower the font size or shorten the line in the code itself.
About this tool
Colors comments, strings, numbers, keywords, function calls and property names with simple lexical rules for each language; it does not parse the code, so rare constructs can be colored plainly. Tabs become spaces at the tab width you pick. Text uses your system monospace font, so the image can look slightly different on another computer. Long lines widen the card unless you pick a wrap width. Up to 2,000 lines; very large images are scaled down to stay under 16.7 million pixels.