Copy a screenshot or image into clipboard, run one command, and paste back clean Markdown.
pac -p -c
pac -cb -cThat is the whole magic trick:
- Copy a screenshot or image.
- Run
pac -p -corpac -cb -c. - Paste the result into ChatGPT, Slack, Discord, GitHub issues or anywhere.
npm install -g paste-as-codeOr try it without installing:
npx paste-as-code --helpRequires Node.js 20 or newer.
Screenshots are where useful text goes to become annoying.
paste-as-code removes the tiny, repetitive steps between “I can see this” and “I can use this”:
- no manual typing
- no file-path friction
- no OCR configuration
- no copy-paste cleanup
- no Markdown wrapping
- no need to paste screenshots or images into LLMs or agents; save tokens by sending the copied text from those images instead of the image itself
Copy any image to your clipboard and turn it into Markdown text.
pac -p
pac -cb
pac -cb -cThat means:
- screenshot or any other image goes in on the clipboard
- OCR runs immediately
- clean Markdown comes back out
- no file paths, no dragging, no waiting around
On macOS, copy a screenshot to your clipboard, then run:
pac -cb -cIf you already have a file:
pac screenshot.pngThe output is Markdown by default:
```ts
const value: number = 1;
```| Command | What it does |
|---|---|
pac screenshot.png |
OCR an image file and print Markdown. |
pac -cb |
Read a screenshot from the clipboard. |
pac -cb -c |
Read clipboard image, OCR it, and copy Markdown back. |
pac screenshot.png -r |
Print raw cleaned OCR text. |
pac screenshot.png -l ts |
Force the Markdown fence language. |
pac screenshot.png -k |
Keep edge-clipped lines that would otherwise be dropped. |
pac screenshot.png --no-preprocess |
Skip image preprocessing if it hurts a specific screenshot. |
Verbose forms are still supported too:
paste-as-code --clipboard --copy
paste-as-code screenshot.png --raw
paste-as-code screenshot.png --lang ts- code screenshots
- error messages
- stack traces
- terminal output
- Discord and Slack snippets
- macOS clipboard screenshots
The OCR pipeline is tuned for code-like screenshots:
- small images are upscaled
- dark-theme screenshots are inverted when needed
- text is normalized and sharpened before OCR
- clipped top/bottom lines can be dropped automatically
- code-friendly Tesseract settings preserve spacing and avoid aggressive dictionary correction
If a specific screenshot gets worse after preprocessing, use:
pac screenshot.png --no-preprocessIf you want to keep clipped lines anyway:
pac screenshot.png --keep-clipped- File input works anywhere the package and native dependencies install successfully.
- Clipboard image input is currently macOS-only.
- Stay tuned for Linux and Windows clipboard support.
npm install
npm run typecheck
npm test
npm run buildManual OCR smoke test:
npm run test:ocr -- screenshot.pngThis repo is published to npm as paste-as-code.
If it saves you time, starring the repo helps other developers find it too.