1. Home
  2. Developer
  3. Code to Image

Code to Image

Turn code into a syntax-highlighted image for sharing.

Runs in your browser · No upload
px
Outer margin
Tab width
Export scale
Preview

Your code is processed in your browser and never sent to a server.

How to use

  1. Paste your code into the input box. The language is auto-detected by default; pick it from the list if the guess is wrong.
  2. Choose a theme (Midnight, Daylight, Dusk) and a background (Sunset, Ocean, Violet, Mint, Slate, or transparent).
  3. Adjust the font size, window title (file name), line numbers, outer margin and line wrapping. The preview updates at once.
  4. Pick an export scale (1x, 2x, 3x) and press Download PNG or Copy image.

For blogs, slides, social posts and docs, this card gives sharper text and a consistent size than a screen capture.

Options

Option Description
Language JavaScript, TypeScript, Python, Java, Kotlin and C#, C and C++, Go, Rust, SQL, Bash, JSON, YAML, HTML and XML, CSS, plain text
Theme Two dark (Midnight, Dusk) and one light (Daylight)
Background Five two-color gradients and transparent. Transparent suits a window-only PNG with no outer margin
Window title bar Draws three dots like a macOS window and a centered title (the file name)
Line numbers You can set the first number, handy for showing the middle of a long file
Wrap long lines Breaks lines at 60, 80, 100 or 120 columns so the image does not grow too wide
Tidy Removes blank lines at both ends and the indent common to every line. Tabs become 2 or 4 spaces

How the language is detected

It guesses from the shape of the code. When unsure it keeps plain text, so choose the language yourself if colors look off.

  • Starts with { or [ and parses as JSON: JSON. Starts with <!DOCTYPE html> or a tag like <div: HTML
  • Starts with SELECT, INSERT INTO or CREATE TABLE: SQL. Shell commands such as #!/bin/bash or npm install: Bash
  • package main with func: Go. fn main(): Rust. #include: C. public class: Java
  • def, elif, print(...): Python. const, =>, console.log: JavaScript, and with : string or interface it becomes TypeScript

How the colors are applied

Instead of parsing the full grammar, a simple tokenizer picks out keywords, strings, numbers, comments, function names, capitalized types, properties and operators. Comments and template strings that span lines, and Python """ strings, are colored line by line. Inside HTML <script> and <style> the JavaScript and CSS rules are used. It is not as precise as an IDE’s syntax analysis, so unusual syntax can be colored differently.

Size and limits

  • Up to 20,000 characters and 200 lines are drawn. Longer code shows the first 200 lines.
  • The scale is lowered automatically so no side exceeds 8,192px, and a notice is shown.
  • Copying the image only works when the browser allows clipboard writes. If not, save a PNG.
  • The font is the monospace font of your device, so letter shapes differ a little between devices, and a saved PNG keeps the look from the device that made it.

Frequently asked questions

How do I make a code screenshot?

Paste the code, pick a theme and background, and save as PNG. No separate capture tool is needed.

Can I save just the window without a background?

Set the outer margin to None and only the window is saved as PNG. The area outside the rounded corners is transparent.

How do I save in high resolution?

Choose 2x or 3x. The screen size stays the same but the pixel count grows, which keeps slides and print sharp.

Do passwords or tokens in my code leave the browser?

No. The image is made on a canvas in this browser and is not sent anywhere. Sharing the saved image is up to you, so check that no passwords or keys are in the code before you publish it.

Related tools: Screenshot Beautifier, JS Beautify and Minify, Color Converter, CSS Gradient Generator, Add Text to Image.

Your code is processed in your browser and never sent to a server.

Can't find the tool you need?

Tell us what you want to do. We build the most requested tools first.