Skip to content
The clipboard copy/paste API for Deno
TypeScript Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.

Deno clipboard library

Build Status
(CI tests on Linux, Mac, Windows)


import { clipboard } from '';

await clipboard.writeText('some text');

const text = await clipboard.readText();

console.log(text === 'some text'); // true


  • use Web Clipboard API
  • use readText and writeText (no read and write, see the spec)
  • work on Linux, macOS, Windows
  • don't bundle any binaries

It will spawn external processes so unfortunately it will require the all-powerful --allow-run flag.

If Deno exposes a Clipboard API (with new permissions like --allow-copy and --allow-paste) then hopefully this will be obsolete. See the relevant issue:


On Linux it requires xsel to be installed (probably installed by default).

The clipboard on Windows always adds a trailing newline if there was none which makes single line strings end with a newline and this module removes the trailing newline on Windows, but it means that if it was there originally then it will still be removed - to preserve single-line strings being single-line, but maybe this is not the right way to do it. The other option would be to preserve the trailing newline but also to get one if it wasn't there. Currently I chose to remove it because newlines in the clipboard sometimes are problematic (like automatically starting commands when pasted into the terminal). TODO: think about it.


For any bug reports or feature requests please post an issue on GitHub.


Rafał Pocztarski
Follow on GitHub Follow on Twitter
Follow on Stack Exchange


MIT License (Expat). See for details.

You can’t perform that action at this time.