Clipboard
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2020.
* Some parts of this feature may have varying levels of support.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
TheClipboard interface of theClipboard API provides read and write access to the contents of the system clipboard.This allows a web application to implement cut, copy, and paste features.
The system clipboard is exposed through the globalNavigator.clipboard property.
All of the Clipboard API methods operate asynchronously; they return aPromise which is resolved once the clipboard access has been completed.The promise is rejected if clipboard access is denied.
All the methods require asecure context.Additional requirements for using the API are discussed in theSecurity consideration section of the API overview topic.
In this article
Instance methods
Clipboard is based on theEventTarget interface, and includes its methods.
read()Requests arbitrary data (such as images) from the clipboard, returning a
Promisethat resolves with an array ofClipboardItemobjects containing the clipboard's contents.readText()Requests text from the system clipboard, returning a
Promisethat is fulfilled with a string containing the clipboard's text once it's available.write()Writes arbitrary data to the system clipboard, returning a
Promisethat resolves when the operation completes.writeText()Writes text to the system clipboard, returning a
Promisethat is resolved once the text is fully copied into the clipboard.
Specifications
| Specification |
|---|
| Clipboard API and events> # clipboard-interface> |