How to Copy to Clipboard in Node.js (Easy Way)

To copy to clipboard in Node.js, you can use the clipboardy package from NPM. First, install it by running the following command at the root of your project directory:

npm i clipboardy

We can use clipboardy to read or write to the system clipboard:

import clipboardy from 'clipboardy';

async function main() {
  await clipboardy.write('butter');
  const text = await;
  console.log(text); // 'butter'


The module can read/write synchronously as well:

import clipboardy from 'clipboardy';


const text = clipboardy.readSync();
console.log(text); // butter


clipboardy is an ES module, and can only be used with the import keyword. The use the import keyword in Node.js, set the the type field to module in your package.json file:


  // ... other fields
  "main": "index.js",
  "type": "module",
  // ... other fields

11 Amazing New JavaScript Features in ES13

This guide will bring you up to speed with all the latest features added in ECMAScript 13. These powerful new features will modernize your JavaScript with shorter and more expressive code.

11 Amazing New JavaScript Features in ES13

Sign up and receive a free copy immediately.

Leave a Comment

Your email address will not be published. Required fields are marked *