A small macOS command-line tool that reads rich pasteboard content and writes Markdown. It uses Swift, Foundation, and AppKit only.
By integration the CLI tool into e.g. LaunchBar 6 (an example action is provided), you can have a workflow where you take copy some text from an app that is not supporting markdown export (e.g. Microsoft Teams AI summaries), run it through the LaunchBar 4 action, then paste it into an app that is not supporting rich text paste (e.g. Mattermost, Text-only editors).
- macOS 13 or newer
- Swift 6 / Xcode 16 or newer
swift build -c release
swift testThe executable is written to .build/release/pasteboard-markdown.
pasteboard-markdown [--stdout] [--clipboard] [--help]
With no flags, the tool replaces the pasteboard contents with Markdown. --stdout prints the result without changing the pasteboard. Combine --stdout --clipboard to do both.
Input preference is HTML, then RTF, then plain text. HTML is converted structurally. RTF preserves bold and italic font traits, paragraphs, and Cocoa text lists; unsupported RTF formatting is reduced to text. Plain text passes through unchanged.
| HTML | Markdown |
|---|---|
p, br |
paragraphs and hard line breaks |
h1…h6 |
headings |
strong, b, em, i |
emphasis |
a |
links |
ul, ol, li |
nested lists |
blockquote |
block quotes |
pre, code |
fenced and inline code |
hr |
thematic breaks |
table, tr, th, td |
GitHub-style tables |
Container tags such as div, section, and article create blocks. Unknown tags are discarded while their text and supported descendants remain. Named basic HTML entities and numeric Unicode entities are decoded. The parser is deliberately not a browser-grade HTML renderer: CSS, images, scripts, styles, definition lists, and layout are not converted.
make installThis installs the binary as ~/.local/bin/pasteboard-markdown. Override the prefix with make install PREFIX=/usr/local.
make install-actionThis installs both the binary and Pasteboard to Markdown.lbaction in ~/Library/Application Support/LaunchBar/Actions. In LaunchBar, run Pasteboard to Markdown. The action replaces the pasteboard, closes the normal LaunchBar interface, and shows a temporary LaunchBar large-type confirmation. It does not create Notification Center entries or expose the Markdown as LaunchBar result items. If LaunchBar does not notice the action immediately, open LaunchBar Index and rescan Actions.
The installer removes downloaded-file quarantine metadata from the copied action bundle. This avoids carrying archive metadata into LaunchBar's Actions directory.
The wrapper expects the default binary path ~/.local/bin/pasteboard-markdown. If you use another PREFIX, edit Contents/Scripts/default.js in the action accordingly.
The converter targets predictable pasteboard fragments, not arbitrary web-page conversion. Its supported subset and fallback order are an explicit compatibility contract. Tests cover HTML and RTF conversion, Unicode, pasteboard type preference, and pasteboard replacement.
0BSD. It permits use, modification, and redistribution without attribution requirements.