You’ll see the picture here, exactly as it will be saved
Nothing to draw yet
Code to Image: Turn Your Code into a Clean Picture
What Is a Code to Image Tool?
It makes a picture of a piece of code, with syntax colors, a little window around it and a background behind it.
You paste the code, pick how it should look, and download a PNG. People use these pictures on slides, in blog
posts and docs, and in social posts where a code block would lose its colors and indentation.
The picture is drawn right here in your browser. Your code isn’t uploaded, and it’s gone when you close or
reload the page (only your settings are remembered). What you see on the right is the exact picture you’ll
get: the preview and the downloaded file are the same drawing.
How to Make a Picture of Your Code
Click Sample in the tool above if you want something to play with first.
Step 1 Paste or Open Your Code
Paste a snippet into the box on the left, open a file with the upload button, or drop a file onto the tool.
When you open a file, its name goes into the window bar, so cart.js shows up at the top of the
picture and the language is picked from the .js.
Step 2 Check the Language
Auto guesses the language and shows its guess, like “Auto (CSS)”. It looks at the file name
first, then at the code. A few lines of SQL with no file name can be hard to tell apart from plain English,
so if the colors look off, pick the language from the list.
Step 3 Pick a Look
Theme: the colors of the card. Midnight and Lime are dark, Daylight and Paper are light, and there are two high contrast themes for projectors and small screens.
Background: a gradient, one color of your choice, or transparent (the checkerboard shows which parts will be see-through).
Padding: the space around the card. None gives you just the card with square corners.
Window adds the bar with three dots; type a file name next to it, or leave it empty.
Step 4 Make It Easy to Read
Set the Font size, turn Line numbers on or off, and choose where long lines
Wrap. Type line numbers in Highlight to mark the lines you’re talking about:
4 marks line 4
3-5 marks lines 3, 4 and 5
2, 7-9 marks line 2 and lines 7 to 9
Tabs sets how wide a tab character is. Code copied from Go or a Makefile often uses tabs, and
4 usually matches what you saw in your editor.
Step 5 Download or Copy
Download PNG (the lime button) saves the picture. The file is named after the window title,
so cart.js becomes cart-js.png. Copy image puts it on your
clipboard for pasting into a chat or a slide, and SVG saves a version where the text stays
text. Pick 2x or 3x for a sharper picture; the size in pixels is shown
under the preview.
Where a Picture of Code Works Well
Slides
Code pasted into a slide tool loses its colors and often its indentation. A picture keeps both. Use 3x, a font
size of 18 px or more, and one of the high contrast themes if the room has a weak projector.
Social posts
Most social sites squash code blocks or don’t have them at all. A short snippet as a picture, with the code in
the post text or a link, gets the best of both.
Docs and blog posts
Good for a “before and after” where you want two snippets side by side, or a highlighted line that points at
the bug. For everything else, a normal code block that people can copy is better.
Try it: a CSS snippet with a highlighted rule
Loads a small button style with the hover rule (lines 9 to 11) highlighted.
.btn:hover{background: #3f6212;}
Try it: Python, a SQL query or a shell script
Each button loads a short sample and switches the language to match.
Tips for a Picture People Can Actually Read
Show less code
Ten lines that make one point beat a whole file. Cut the imports and the boilerplate, and leave a comment
like // ... where you skipped something.
Keep lines short
Long lines make the picture wide, and then everything shrinks to fit the screen. Set Wrap to 60 or 80, or
better, break the line yourself where it makes sense (see the example below).
Go bigger on the font
15 px is fine for a blog. On a phone feed or a slide, 18 to 22 px reads much better, because the picture is
usually shown smaller than its real size.
Contrast counts
Every text color in every theme here is at least 4.5:1 against its card, the level WCAG asks for normal text,
and the two high contrast themes are at 7:1 or more. Pale gray comments on a dark card are often the first
thing to vanish on a projector.
Tidy it first
Mixed indentation looks worse in a picture than in an editor. Run HTML through the
HTML Formatter or CSS through the CSS Formatter
before you paste it here.
Highlight one thing
Marking the two lines you’re talking about tells the reader where to look. Marking half the snippet tells them
nothing.
Example: the same line, before and after
One long line (it gets wrapped wherever it hits the edge):
const total = items.filter((item) => item.inStock && !item.hidden).map((item) => item.price * item.qty).reduce((a, b) => a + b, 0);
Broken up by hand, one step per line:
const total = items
.filter((item) => item.inStock && !item.hidden)
.map((item) => item.price * item.qty)
.reduce((a, b) => a + b, 0);
And messy CSS next to the formatted version:
/* Messy */.btn{padding:12px 20px;border:0;background:#4d7c0f}/* After the CSS Formatter */.btn{padding: 12px 20px;border: 0;background: #4d7c0f;}
Add Alt Text When You Post It
A screen reader can’t read the code in a picture, so it reads the alt text instead. Say what the code does, in a
sentence, rather than “screenshot of code”. Most social sites have an “Add description” or “ALT” button on the
picture; in HTML and Markdown it looks like this:
HTML:
<imgsrc="order-total.png"alt="JavaScript function orderTotal: adds up price times
quantity for each item, then takes 10% off for regulars">
Markdown (a README or a blog post):

The code from the picture, ready to copy:
For a short snippet you can put the whole code in the alt text. For anything longer, describe it and link to the
code.
Share the Code as Text Too
A picture of code is for looking at. Nobody can copy it, search for it, run it through a translator or fix a typo
in it, and code that people retype from a picture comes with new bugs. So whenever you post a picture, put the
code somewhere it can be copied: in the post’s text, a gist, a repo or a code block right under the image. If
you’re asking for help with a bug, skip the picture and paste the text. The people helping you will want to run
it.
Need a picture of a web page or a component instead of its source? The
HTML to Image converter renders the HTML and saves what it looks like.
The Themes
The lowest contrast is the faintest text color in the theme (usually comments or line numbers) against the card
and against a highlighted line. 4.5:1 passes WCAG AA for normal text, 7:1 passes AAA.
Theme
Card
Some of its colors
Lowest contrast
Midnight
Dark #111827
5.11:1
Lime
Dark #0b0f19
5.25:1
Daylight
Light #ffffff
4.82:1
Paper
Light #fbf7ee
5.37:1
High contrast (dark)
Dark #000000
7.94:1
High contrast (light)
Light #ffffff
7.72:1
What It Can’t Do
Only your system’s monospace font. The picture uses whichever of SF Mono, Menlo, Consolas,
Liberation Mono or DejaVu Sans Mono your computer has, so the same code can look a touch different on another
computer. You can’t pick a web font here.
The colors come from a simple highlighter. It knows the common parts of each language, but an
unusual construct can end up in plain text color. It never changes your code, only how it’s colored.
JSON, XML and other languages aren’t colored. Pick Plain text for those.
Up to 500 lines. Longer code is cut, and the tool tells you. Very big pictures are made
at a lower scale so your browser can handle them.
Emoji and CJK characters come from a fallback font, so they can look wider or a bit different from the code around them.
No animated GIFs and no typing animation. It makes one still picture.
Frequently Asked Questions
How do I turn code into an image?
Paste your code into the box on the left, or open a code file. The picture on the right updates as you type. Pick a theme and a background, turn the window bar and line numbers on or off, then click Download PNG. Copy image puts the same picture on your clipboard so you can paste it straight into a chat or a slide.
Which languages get syntax colors?
HTML (including the CSS and JavaScript inside <style> and <script>), CSS, JavaScript and JSX, TypeScript and TSX, Python, SQL and Bash. Anything else works as plain text. Auto picks the language from the file name in the window bar first (app.py, styles.css), then from the code itself. If it guesses wrong, pick the language yourself.
Is my code uploaded anywhere?
No. The picture is drawn in your browser and saved straight from this page. The code isn’t sent to a server, and it isn’t kept after you leave or reload the page. Only your settings, like the theme and font size, are remembered in this browser.
What size should the picture be?
Pick the scale for where it’s going. 2x (the default) stays sharp on phones and most laptops, and it’s right for blog posts and social media. Use 3x for slides on a big screen. The status line under the picture shows the exact size in pixels. Fewer lines and a font size of 16 to 20 px read better than squeezing in a whole file.
Can I highlight some lines?
Yes. Type the line numbers in the Highlight box, like 4 for one line, 3-5 for a range, or 2, 7-9 for both. Those lines get a colored band and a mark on the left edge. The numbers count from the first line of what you pasted.
Why do emoji or Chinese characters look different from the rest?
The picture uses your system’s monospace font (Menlo, Consolas, SF Mono and so on). Most of them don’t have emoji or CJK characters, so your browser borrows those from another font. They still show, they’re just a little wider or a different style than the letters around them.
Should I download PNG or SVG?
PNG for almost everything: it looks the same everywhere and every app opens it. SVG keeps the text as text, so it stays sharp at any size and the file is small, but it’s drawn with the fonts of the computer that opens it, so the spacing can shift a little. Use SVG for print or for a design tool you’ll edit it in.
Is it OK to share code as an image?
For a quick look, yes: an image keeps your colors and layout in a tweet or on a slide. But nobody can copy, search or translate the code in a picture, and screen readers can’t read it. Always add alt text that says what the code does, and share the code itself too, in a gist, a repo or the post’s text.