A CLI tool that converts Markdown to clipboard with multiple formats (plain text and HTML), enabling rich-text pasting into applications like email clients, word processors, and note-taking apps.
When you copy Markdown text and paste it into applications like Gmail, Notion, or Word, you typically get the raw Markdown syntax rather than formatted text. mdcopy solves this by:
- Converting Markdown to rich text and copying it to your clipboard in multiple formats simultaneously (plain text, HTML)
- Allowing you to paste formatted content into virtually any application
- Embedding images directly in the clipboard so they paste inline
- Syntax highlighting code blocks with customizable themes
- Rendering mermaid diagrams as images inline
brew install tarqd/tap/mdcopycargo install --path .# Read from stdin
echo "# Hello World" | mdcopy
# Read from file
mdcopy -i document.md
# Output to stdout
mdcopy -i document.md -o -| Option | Description |
|---|---|
-i, --input <FILE> |
Input file (use - for stdin, default: stdin) |
-o, --output <FILE> |
Output to file or stdout (use - for stdout) |
-r, --root <DIR> |
Base directory for resolving relative image paths |
-e, --embed |
Embed all images (local and remote) |
-c, --config <FILE> |
Path to configuration file |
--strict |
Fail on errors instead of graceful fallback |
-v, --verbose |
Increase logging verbosity (-v, -vv, -vvv) |
-q, --quiet |
Suppress all output except errors |
| Option | Description |
|---|---|
--highlight |
Enable/disable syntax highlighting (default: enabled) |
--highlight-theme <NAME> |
Theme to use (default: base16-ocean.dark) |
--highlight-themes-dir <DIR> |
Custom themes directory |
--highlight-syntaxes-dir <DIR> |
Custom syntaxes directory |
--list-themes |
List available themes and exit |
| Option | Description |
|---|---|
-m, --mermaid |
Render mermaid diagrams as images (default: enabled) |
--mermaid-format <FORMAT> |
Output format: svg, png, jpeg (default: png) |
--mermaid-optimize |
Optimize rasterized output |
--mermaid-max-width <PX> |
Max rasterization width (default: 1200) |
--mermaid-max-height <PX> |
Max rasterization height (default: 800) |
Supports GitHub Flavored Markdown (GFM) including:
- Headings, paragraphs, and text formatting (bold, italic, strikethrough)
- Code blocks with syntax highlighting and inline code
- Ordered and unordered lists
- Blockquotes and horizontal rules
- Links and images
- Tables with column alignment
Mermaid code blocks are rendered as images and embedded directly in the clipboard output. This means flowcharts, sequence diagrams, ERDs, and other mermaid diagrams paste as images into Google Docs, email, Notion, and other apps.
```mermaid
flowchart LR
A[Markdown] --> B[mdcopy] --> C[Clipboard]
```- Renders to SVG internally using mermaid-rs, then rasterizes to PNG/JPEG at 2x for HiDPI
- Configure format, max dimensions, and optimization via CLI flags or config file
- Gracefully falls back to a code block if rendering fails (unless
--strictis set)
Code blocks are syntax highlighted using the syntect library with base16-ocean.dark as the default theme.
- Supports 50+ programming languages out of the box
- Use
--list-themesto see available themes - Add custom themes (
.tmThemefiles) to~/.config/mdcopy/themes/ - Add custom syntax definitions to
~/.config/mdcopy/syntaxes/ - Configure language aliases (e.g., map
jsxtoJavaScript)
Images can be embedded as base64 data URLs in HTML output.
Embedding modes:
--embed-local(default): Embed only local/relative images--embed/-e: Embed both local and remote images (fetches remote images)--no-embed/-E: Don't embed any images, keep original URLs
When outputting to clipboard (default), mdcopy sets two formats simultaneously:
- Plain text: Original Markdown source
- HTML: Rendered HTML with embedded images and syntax highlighting
This allows pasting into virtually any application with appropriate formatting.
mdcopy includes a built-in Model Context Protocol (MCP) server that exposes its rendering capabilities as tools for AI assistants. This lets AI agents copy formatted markdown and render diagrams on your behalf.
| Tool | Description |
|---|---|
render_markdown_to_clipboard |
Render markdown to rich HTML and copy to the system clipboard. Accepts a file path or raw text. Supports image embedding and optimization. |
render_mermaid |
Render a mermaid diagram to an image file (SVG, PNG, or JPEG). Accepts source text or a file path. Useful for generating diagram assets. |
claude mcp add mdcopy -- mdcopy mcpAdd to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"mdcopy": {
"command": "mdcopy",
"args": ["mcp"]
}
}
}codex mcp add mdcopy -- mdcopy mcpOr add to ~/.codex/config.toml:
[mcp_servers.mdcopy]
command = "mdcopy"
args = ["mcp"]For remote or multi-client access, use the HTTP transport:
mdcopy mcp --transport http --listen 127.0.0.1:3100The server will be available at http://127.0.0.1:3100/mcp.
mdcopy looks for a TOML configuration file at:
- Linux:
$XDG_CONFIG_HOME/mdcopy/config.toml(default:~/.config/mdcopy/config.toml) - macOS:
~/Library/Application Support/mdcopy/config.toml, with fallback to~/.config/mdcopy/config.tomlif the Application Support directory doesn't exist
Configuration precedence: CLI arguments > environment variables > config file > defaults
# Default settings
embed = "local"
strict = false
[highlight]
enable = true
theme = "base16-ocean.dark"
# Custom language mappings
[highlight.languages]
jsx = "JavaScript"
tsx = "TypeScript"
[mermaid]
embed = true
format = "png"
optimize = true
max_width = 1200
max_height = 800All settings can be configured via environment variables with the MDCOPY_ prefix:
MDCOPY_INPUT- Input file pathMDCOPY_OUTPUT- Output file pathMDCOPY_ROOT- Base directory for imagesMDCOPY_EMBED- Embedding mode (all, local, none)MDCOPY_STRICT- Strict mode (true/false)MDCOPY_HIGHLIGHT- Enable highlighting (true/false)MDCOPY_HIGHLIGHT_THEME- Theme nameMDCOPY_HIGHLIGHT_THEMES_DIR- Custom themes directoryMDCOPY_HIGHLIGHT_SYNTAXES_DIR- Custom syntaxes directory
# Convert README and copy to clipboard
mdcopy -i README.md
# Embed all images including remote ones
mdcopy -i doc.md --embed
# Skip image embedding entirely
mdcopy -i doc.md --no-embed
# Set custom base directory for relative image paths
mdcopy -i doc.md --root /path/to/images
# Use a specific syntax highlighting theme
mdcopy -i doc.md --highlight-theme "Solarized (dark)"
# List all available themes
mdcopy --list-themes
# Disable syntax highlighting
mdcopy -i doc.md --no-highlight
# Render mermaid diagrams as SVG instead of PNG
mdcopy -i doc.md --mermaid-format svg
# Fail on missing images instead of warning
mdcopy -i doc.md --strict
# Debug output
mdcopy -i doc.md -vvMIT