
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
clipboard-copy
Advanced tools
The goal of this package is to offer simple copy-to-clipboard functionality in modern web browsers using the fewest bytes. To do so, this package only supports modern browsers. No fallback using Adobe Flash, no hacks. Just 30 lines of code.
Unlike other implementations, text copied with clipboard-copy is clean and
unstyled. Copied text will not inherit HTML/CSS styling like the page's background
color.
Supported browsers: Chrome, Firefox, Edge, Safari.
Works in the browser with browserify!
npm install clipboard-copy
const copy = require('clipboard-copy')
button.addEventListener('click', function () {
copy('This is some cool text')
})
successPromise = copy(text)Copy the given text to the user's clipboard. Returns successPromise, a promise that resolves if the copy was successful and rejects if the copy failed.
Note: in most browsers, copying to the clipboard is only allowed if copy() is
triggered in direct response to a user gesture like a 'click' or a 'keypress'.
clipboard-copy (this package): 524 B gzippedclipboard-js: 1.7 kB gzippedclipboard: 3.2 kB gzippedTesting this module is currently a manual process. Open test.html in your web browser and follow the short instructions. The web page will always load the latest version of the module, no bundling is necessary.
MIT. Copyright (c) Feross Aboukhadijeh.
The clipboard-js package provides similar functionality to clipboard-copy, allowing you to copy text to the clipboard. It offers a more comprehensive API with additional features such as reading from the clipboard and handling clipboard events.
The copy-to-clipboard package is another alternative that provides a simple way to copy text to the clipboard. It is lightweight and easy to use, similar to clipboard-copy, but it also includes support for older browsers.
The clipboard-polyfill package offers a polyfill for the modern Clipboard API, providing a more robust solution for copying text to the clipboard. It supports both writing to and reading from the clipboard, making it a more versatile option compared to clipboard-copy.
FAQs
Lightweight copy to clipboard for the web
The npm package clipboard-copy receives a total of 581,445 weekly downloads. As such, clipboard-copy popularity was classified as popular.
We found that clipboard-copy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.