Code Screenshot Generator
Paste code, pick a theme and window style, and export a crisp PNG or SVG — highlighted and rendered entirely on this device.
198 characters · 11 lines
Image preview — scaled to fit this box
400 × 331 px · 11 lines, drawn on this device.
rendered with the viewer's monospace font — SVG opened elsewhere may shift slightly; PNG export freezes this device's rendering
Do it offline:$ silicon main.rs -o code.png
How to use it
- Paste the snippet in the editor. Up to 20,000 characters and 400 lines are drawn; tabs become two spaces first.
- Pick the language and theme. Every theme keeps every token color at a 4.5:1 contrast ratio or better against its background, so the image stays readable where it lands.
- Shape the window: chrome bar with three dots, an optional title up to 60 characters, line numbers, padding 16–128 px, font size 12–20 px, corner radius up to 24 px.
- Export. Download PNG rasters the image at 1× or 2× on this device; Download SVG hands over the exact vector document, byte for byte; Copy SVG puts that markup on the clipboard.
Paste a snippet, pick one of 12 languages and 6 themes, and download a crisp PNG or SVG of it — window chrome, line numbers and padding included. Everything renders on this device: the highlighter, the SVG and the PNG raster are all local, and your code never leaves the device. Carbon's repository has been quiet since December 2024; this page is the maintained, private alternative.
How it works
The highlighter is a fast built-in highlighter covering keywords, strings, comments and numbers for 12 languages — not a full grammar engine like TextMate; unknown code stays readable plain. Each language is an ordered list of rules tried at the current position only, so hostile input cannot make it backtrack — a wall-clock test holds it to a time budget.
Layout never measures text. In a monospace font every character advances the same distance — the CSS ch unit is defined as the advance of the digit zero — so width is character count × font size × 0.60, the advance ratio of the house monospace faces. The same input and options therefore always produce the same bytes.
The SVG names a font stack but never embeds or fetches a font, so it is rendered with the viewer's monospace font — SVG opened elsewhere may shift slightly; PNG export freezes this device's rendering.
Examples
function greet(name) {
// wave first
return `hi, ${name}!`;
}291 × 184 px · 4 lines · svg sha-256 16b398a882e7A JavaScript snippet in the dark Ink dusk theme with chrome, a greet.js title and line numbers. The comment, keyword, template string and punctuation take distinct colors.
SELECT id, email
FROM users
WHERE created_at >= '2026-01-01'
ORDER BY created_at DESC
LIMIT 20;356 × 168 px · 5 lines · svg sha-256 a6efd4e43e01A SQL query in the light Paper theme, no chrome, no gutter. SQL keywords match in any letter case; the quoted date is a string token.
def fib(n: int) -> int:
# iterative
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a568 × 480 px · 6 lines · svg sha-256 6b2385a06af1A Python function at 2× export scale: the SVG doubles its width and height attributes while the drawing stays identical, so the PNG comes out at 568 × 480 instead of 284 × 240.
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
Twelve languages, and an honest fallback
The pickers cover plain, javascript, typescript, json, html, css, python, go, rust, sql, bash and yaml. Anything the rules do not recognize keeps the theme's foreground color; a snippet matching nothing raises a visible notice instead of guessed colors.
Tabs and Windows line endings are normalized first
A tab becomes exactly two spaces and CRLF becomes a plain newline before anything is counted or measured, so the same file pasted from macOS and from Windows produces identical bytes.
Long lines widen the image — nothing wraps
Wrapping would change what the code says, so a line past 120 characters grows the image horizontally and a warning chip says so. If that is too wide, break the line in the editor.
Full-width glyphs can clip
Width arithmetic gives every UTF-16 code unit the 0.6 em advance of the digit zero, but CJK glyphs and many emoji draw wider in monospace fonts — a line heavy with them can clip at the computed right edge. Keep such lines short.
The gutter and title sit inside the geometry
Line numbers add their digit count plus a two-character gap to the width; the chrome bar adds 36 pixels of height and keeps a 160-pixel minimum width for the three dots.
A shared link restores the style, never the code
The permalink envelope has fields for language, theme, chrome, title and the numbers — and no field for code at all. ray.so's share links carry the snippet itself in the address; a link from this page cannot.
Common errors
the code is 20,001 characters — this tool's limit is 20,000 characters- The refusal prints the length actually submitted next to the cap, so it is clear how much has to go; the 400-line ceiling reads the same way.
`scala` is not one of this tool's languages — expected one of plain, javascript, typescript, json, html, css, python, go, rust, sql, bash, yaml- A language outside the curated twelve is refused with the full accepted list rather than silently downgraded. For anything else, choose plain — uncolored but exact.
FAQ
Is my code uploaded when I make a screenshot?
No. The highlighter, the SVG builder and the PNG raster run in this tab, so your code never leaves the device — verify in the network panel as you type and export.
Why does my niche language render as plain text?
Because this is a fast built-in highlighter covering keywords, strings, comments and numbers for 12 languages — not a full grammar engine like TextMate; unknown code stays readable plain. Wrong colors would be worse than none, so nothing is guessed.
Should I download the PNG or the SVG?
PNG for anywhere pixels are expected, because it freezes exactly what this device drew. SVG stays sharp at any zoom, but it names a font stack rather than embedding one, so another machine may draw it with a different monospace face.
Can someone recover my code from a shared link?
Not from a link made here: the envelope carries language, theme and layout numbers — structurally no code field. Its one text field, the window title, is flagged before sharing and dropped on restore when it looks credential-shaped.
Keyboard shortcuts
- ⌘/Ctrl + C
- Copy the SVG markup while focus is in the tool and no text is selected; a real selection copies itself.
- ⌘/Ctrl + Shift + C
- Copy the SVG markup even while a text selection exists.
- ⌘/Ctrl + S
- Download code.png — this page's raster, not the browser's save dialog.
- ? or ⌘/Ctrl + /
- Open the keyboard shortcut overlay, which also documents that Tab moves focus out of the editor.
- Esc
- Close the topmost dialog; every field keeps its value.