Copy rich text anywhere on macOS, get clean Markdown on your clipboard.
Select text in a browser, Notion, Word, Mail — press your hotkey — paste Markdown. Headings, links, lists, bold and italics survive. No web service, no upload, nothing leaves your machine.
macOS has no built-in way to convert formatted text to Markdown. The usual
workarounds are online converters (which means pasting your content into
someone else's server) or a browser extension that only works in the browser.
clip2md is a 50-line shell script that works in every app.
- macOS
- pandoc —
brew install pandoc
git clone https://github.com/tillheidrich/clip2md.git
cd clip2md
./install.shThis copies the script to /usr/local/bin/clip2md. Use a different location
with PREFIX=~/bin ./install.sh.
clip2md presses ⌘C for you, which macOS treats as controlling your computer.
Without permission the script silently converts whatever was already on the
clipboard instead of your selection.
Open System Settings → Privacy & Security → Accessibility and enable the app that runs the script — your terminal, Raycast, Shortcuts, Automator or Stream Deck. The exact entry depends on how you trigger it (see below).
clip2md is a plain command, so anything that can run a shell command works.
Raycast / Alfred — add a script command that runs clip2md.
Shortcuts — new shortcut, add Run Shell Script with clip2md, assign a
keyboard shortcut in the shortcut's settings.
Automator Quick Action — new Quick Action, Run Shell Script, input "no
input", body clip2md. Then assign a key under System Settings → Keyboard →
Keyboard Shortcuts → Services.
Stream Deck — use a System → Open action pointing at a small .app
wrapper, or the Terminal plugin.
| Variable | Default | Meaning |
|---|---|---|
CLIP2MD_TIMEOUT_MS |
2000 |
How long to wait for the copy to land before converting. Raise it for slow apps. |
CLIP2MD_TIMEOUT_MS=4000 clip2md- Remember the current clipboard.
- Send ⌘C to copy the selection.
- Poll until the clipboard actually changes, or the timeout expires — rather
than guessing a fixed
sleep. - Read the
public.htmlflavour of the clipboard and run it through pandoc (gfm, unwrapped). - If there is no HTML flavour, keep the plain text unchanged.
- Write the result back to the clipboard.
Because step 2 is a no-op when nothing is selected, running clip2md with an
empty selection converts whatever is already on the clipboard. That is
intentional and useful.
- Images become Markdown image references pointing at the original URLs. The files themselves are not downloaded.
- Complex tables and nested layouts come out as pandoc renders them, which is usually good but not always pretty.
- If the copied selection is byte-identical to the previous clipboard content, the script waits the full timeout before continuing. The output is still correct, just slower.
MIT — see LICENSE.