· 7 min read
Code screenshots for X: Carbon and Ray.so vs capturing your editor (and the accessibility caveat)
Carbon, Ray.so or a capture of your real editor? What each is good for, how to make either accessible, and the terminal secrets that end up in the image.
By Cleanss team
X cannot render a code block, so developers post pictures of code. There are two ways to make one: paste the code into a generator like Carbon or Ray.so, or capture the editor or terminal you already have open. Both carry a cost that developers argue about in public, which is that an image of code is not text. This post compares the two routes, shows how to do the capture route cleanly, and ends with the two things to do every time: write alt text and check for secrets.
For the whole workflow, see How to make screenshots look professional.
Why people do it at all
The case for images is engagement and necessity. In a DEV thread on sharing code with Carbon, one commenter reports that images get a much higher engagement rate than Markdown snippets or gists, another notes that sites like Twitter have no way to display code, and the author concedes there is no better option inside a tweet short of linking out to a gist.
The case against is accessibility and searchability. An Ionic forum thread is titled Posting code as images considered harmful because screen readers cannot process the image; Jake Worth argues that even with alt text information is lost and nothing is searchable; a Zig community post points out that text works with screen readers and braille displays; and a University of Hawaii course assigns a reading titled "Ceci n'est pas une programme" to teach students not to post images of code. GitHub's own docs team tells its writers to avoid screenshots of command-line interfaces and provide the commands as text, because screenshots privilege sighted users.
Both sides are right. On X the image is the only thing that renders, so the honest position is: post the image, and also post the text.
Generator or capture?
| Carbon | Ray.so | Capture your editor | |
|---|---|---|---|
| How it works | Paste code into a web page, style it, export an image | Same, with fewer options | Screenshot the window you are looking at |
| Options | More themes and settings | Deliberately few, so it is quicker to use | Whatever your editor already shows |
| Shows real state | No, only the text you paste | No | Yes: the error, the diff, the test output, the cursor |
| Terminal output | Only if you paste it | Only if you paste it | Yes, exactly as it ran |
| Secrets risk | Lower, you chose what to paste | Lower | Higher, everything in the window is in the image |
| Matches your other screenshots | Separate look | Separate look | Same frame and background as your UI shots |
Both are open source on GitHub, and neither site lists a price. Carbon exports PNG or SVG at 1x, 2x or 4x, can open the image in the browser, and can copy it to the clipboard (Carbon on GitHub). Ray.so, made by Raycast, saves PNG or SVG at 2x, 4x or 6x and can copy the image or a share URL (Ray.so on GitHub).
The generators win for a clean snippet with no context: a five-line function, a config block, a one-liner. Marc Littlemore's write-up on pretty code screenshots and Amit Merchant's list of the tools he uses both cover that workflow well, and a public Xnapper feedback gist catalogues several more, snappify and carbon.now.sh among them.
Capture wins when the point is what happened, not what the code says: a stack trace next to the line that threw it, a failing test, a diff in the editor, a terminal session. Pasting those into a generator strips the context that made them worth sharing.
Capturing the editor cleanly
Cleanss is a screenshot app for Mac and Windows; this is the capture route in it, with Mac shortcuts (on Windows, use Ctrl in place of ⌘). Any capture app with a window picker and a blur tool will do the same job.
- Capture the window. Open the Cleanss editor from the menu bar icon (the system tray on Windows), click Window at the top, and pick the editor or terminal from the window list. You get that window alone at full native resolution, with the desktop and your other windows left out.
- Open it in the editor. If you started from an area capture instead, click Edit on the corner thumbnail.
- Pick a canvas X will show in full. X displays a single photo in full when it is between 2:1 and 3:4. The 16:9, 16:10, 4:3, 1:1 and 4:5 presets all sit inside that range; 16:9 suits a wide editor window, 4:5 a tall terminal.
- Frame and background. Choose a window frame (light, dark or glass) that matches your editor's theme, and a graphite, solid or shader background. If your other posts use a particular look, reuse it here so your feed is one set, not two.
- Run the sensitive-info scan. It reads the screenshot on the device and outlines emails, card numbers, passwords, API keys and tokens, secret lines from .env files, and IPv4 addresses. Blur all covers them. It does not look for hostnames or domain names, so press B and blur anything else that is private by hand: hostnames, internal paths, a colleague's name in a git log.
- Add a label if it needs one. Press T. The Mono font is there for a filename or a command. Keep it to a few words; the explanation belongs in the post text.
- Export. ⌘C copies the image to paste into the compose box; ⌘S saves a PNG at full native resolution.
The whole thing is one capture and a few clicks, which is the difference from the generator route: you never leave the thing you were looking at.
For per-app notes see screenshotting a terminal and iTerm and screenshotting VS Code. For sizing beyond X, see screenshots for X and LinkedIn.
The secrets-in-terminal problem
A terminal capture shows everything on screen: environment variables you printed earlier, the token in a curl command, the key in a .env you opened to check something. Resend's guidance on leaked API keys is that a key that has appeared in a public gist, a client-side app or a shared screenshot should be assumed scraped already. A YouTube API guide says the same: a key in a commit, a screenshot or a log file should be treated as compromised. This is not theoretical; a Tom's Guide forum thread records a game key leaked through a screenshot tool's upload workflow.
Two things make it worse for images specifically. None of the common secret scanners (TruffleHog, Gitleaks, GitGuardian) is documented as OCR-scanning images, so a key in a PNG gets past the tooling that would have caught it in a commit. And pixelation is not a fix: a Hacker News commenter warns that, with considerable effort, pixelated text can be recovered, and Bishop Fox's Unredacter work recommends black bars over the whole text. Use a strong blur that leaves nothing legible, or a solid bar, and if a real key was ever visible, revoke it. The full version is in how to hide API keys in screenshots.
Alt text: the part everyone skips
Whichever route you take, the image needs two companions.
Alt text. GitHub's style guide asks for alt text of 40 to 150 characters that begins "Screenshot of…". For code, say what the code is and what it shows, not the code itself: "Screenshot of a Python function that retries a request three times, with the failing test output below it." Add it when you attach the image: on the web, click Add description; in the apps, tap +Alt. X allows up to 1,000 characters per image (X Help Center).
The text itself. Put the snippet somewhere a screen reader, a search engine and a copy-paste can reach it: a gist, a repo, a reply with the code in plain text. Jake Worth's objection, that information is lost even with alt text, is answered only by the text existing somewhere. The image is the hook; the text is the content.
FAQ
How do I share code on X without a screenshot?
You mostly cannot; X does not render code blocks. The workable pattern is an image for the timeline plus a link to a gist or repo in the same post or a reply, so the code also exists as text.
Is Carbon or Ray.so better for code screenshots?
Ray.so has fewer options and is quicker; Carbon gives more control. Neither shows real editor state or terminal output unless you paste it in, so for errors, diffs and test runs, capture the window instead.
Is it safe to post a screenshot of my terminal?
Only after you have checked it. Anything visible, including tokens, keys and internal hostnames, should be treated as public once posted. Blur or bar it so nothing is legible, and if a key was shown, revoke it.
If you want to try the capture route, download Cleanss for Mac or Windows.