clipboard-rs

Cross-platform Rust API to read, write, and watch the system clipboard

Library
Cargo
v0.3.5
178stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
59/100Fair
Development Activity44
Maintenance60
Community56
Maturity48
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture84
Code Quality82
Innovation75
Learning Curve80

clipboard-rs is a cross-platform Rust library for getting and setting system clipboard content. It handles plain text, HTML, rich text, PNG images, and files, and can also monitor the clipboard for changes through a watcher API.

It supports Windows, macOS, and Linux (X11, with optional Wayland), plus beta iOS support, exposing a uniform Clipboard trait and a format-aware API so you can query available formats and read or write arbitrary type identifiers. It is commonly used in Tauri and Electron-adjacent Rust desktop tooling.

What You Get

  • Read and write plain text, HTML, and rich text
  • Read and write PNG images and file lists via clipboard
  • A clipboard-change watcher for monitoring updates
  • Format enumeration via available_formats and custom type identifiers
  • Cross-platform backends for Windows, macOS, X11, and Wayland

Common Use Cases

  • Building copy/paste features into Rust desktop apps
  • Watching the clipboard to power a clipboard-history manager
  • Transferring images or files through the system clipboard
  • Reading rich text or HTML content set by other applications

Under The Hood

Architecture - The crate defines a common Clipboard trait and shared types in lib.rs and common.rs, then dispatches to per-OS implementations under src/platform (win.rs, macos.rs, x11.rs, wayland.rs, ios.rs) selected by target. The watcher API wraps each platform’s native change notification so applications receive callbacks when clipboard contents change, while the format-identifier system lets callers read or write arbitrary MIME-like types.

Tech Stack - Rust (2021 edition, MSRV 1.67) with image as an optional default dependency for PNG/JPEG handling, wl-clipboard-rs behind a wayland feature, and objc2 bindings for Apple platforms. Feature flags gate image support and Wayland so downstream builds only pull what they need.

Code Quality - The repository ships an integration test suite under tests/ covering strings, files, images, and the change watcher, plus GitHub Actions CI, a CHANGELOG, and runnable examples. Platform-specific code is cleanly isolated per module, and maintenance is consistent across recent releases.

API Design - The API is uniform and ergonomic: a Clipboard/ClipboardContext exposes typed getters and setters (get_text, set_image, etc.) plus available_formats for discovery, and a watcher context handles change subscriptions. Bilingual documentation and examples ease onboarding, with the main nuance being platform capability differences captured in the README’s support matrix.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search