Async clipboard
The Clipboard interface of the Clipboard 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.
EventTarget Clipboard The system clipboard is exposed through the global Navigator.clipboard property.
All of the Clipboard API methods operate asynchronously; they return a Promise which is resolved once the clipboard access has been completed. The promise is rejected if clipboard access is denied.
All the methods require a secure context. Additional requirements for using the API are discussed in the Security consideration section of the API overview topic.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 66 | 79 | 63 | 13.1 | 66 | 13.4 | |
| The read() method of the Clipboard interface requests a copy of the clipboard's contents, fulfilling the returned Promise with the data. | 76 | 79 | 127 | 13.1 | 76 | 13.4 |
| The readText() method of the Clipboard interface returns a Promise which fulfills with a copy of the textual contents of the system clipboard. | 66 | 79 | 125 | 13.1 | 66 | 13.4 |
type_image-png Supports `image/png` MIME type | 76 | 79 | 127 | 13.1 | 76 | 13.4 |
type_text-html Supports `text/html` MIME type | 86 | 86 | 127 | 13.1 | 86 | 13.4 |
type_text-plain Supports `text/plain` MIME type | 76 | 79 | 127 | 13.1 | 76 | 13.4 |
| The write() method of the Clipboard interface writes arbitrary ClipboardItem data such as images and text to the clipboard, fulfilling the returned Promise on completion. This can be used to implement cut and copy functionality. | 76 | 79 | 127 | 13.1 | 76 | 13.4 |
| The writeText() method of the Clipboard interface writes the specified text to the system clipboard, returning a Promise that is resolved once the system clipboard has been updated. | 66 | 79 | 63 | 13.1 | 66 | 13.4 |
| The ClipboardItem interface of the Clipboard API represents a single item format, used when reading or writing clipboard data using Clipboard.read() and Clipboard.write() respectively. | 76 | 79 | 127 | 13.1 | 84 | 13.4 |
| The ClipboardItem() constructor creates a new ClipboardItem object, which represents data to be stored or retrieved via the Clipboard API clipboard.write() and clipboard.read() methods, respectively. | 133 | 133 | 127 | 13.1 | 98 | 13.4 |
| The getType() method of the ClipboardItem interface returns a Promise that resolves with a Blob of the requested MIME type or an error if the MIME type is not found. | 76 | 79 | 127 | 13.1 | 84 | 13.4 |
| The read-only presentationStyle property of the ClipboardItem interface returns a string indicating how an item should be presented. | | | 127 | 13.1 | | 13.4 |
| The read-only types property of the ClipboardItem interface returns an Array of MIME type available within the ClipboardItem. | 76 | 79 | 127 | 13.1 | 84 | 13.4 |
| The clipboard read-only property of the Navigator interface returns a Clipboard object used to read and write the clipboard's contents. | 66 | 79 | 63 | 13.1 | 66 | 13.4 |
permission_clipboard-write Experimental `clipboard-write` permission | 64 | 79 | | | 64 | |
- The user must grant the `clipboard-read` permission.
- The user must grant the `clipboard-read` permission.
- This method must be called within user gesture event handlers.
- A paste prompt is displayed when the clipboard is read. If the clipboard contains same-origin content, the prompt is suppressed.
- Web extensions with the `clipboardRead` permission in their manifest can read data without the paste prompt displaying. Prior to Firefox 147, extensions without this permission were unable to read clipboard data.
- The user must grant the `clipboard-read` permission.
- The user must grant the `clipboard-read` permission.
- The user must grant the `clipboard-read` permission.
- This method must be called within user gesture event handlers.
- A paste prompt is displayed when the clipboard is read. If the clipboard contains same-origin content, the prompt is suppressed.
- Web extensions with the `clipboardRead` permission in their manifest can read data without the paste prompt displaying. Prior to Firefox 147, extensions without this permission were unable to read clipboard data.
- The user must grant the `clipboard-read` permission.
- From version 107, this method must be called within user gesture event handlers, or the user must grant the `clipboard-write` permission.
- Before version 107, the user must grant the `clipboard-write` permission.
- This method must be called within user gesture event handlers.
- Web extensions with the `clipboardWrite` permission in their manifest can write data without a user gesture.
- From version 107, this method must be called within user gesture event handlers, or the user must grant the `clipboard-write` permission.
- Before version 107, the user must grant the `clipboard-write` permission.
- From version 107, this method must be called within user gesture event handlers, or the user must grant the `clipboard-write` permission.
- Before version 107, the user must grant the `clipboard-write` permission.
- From version 107, this method must be called within user gesture event handlers, or the user must grant the `clipboard-write` permission.
- Before version 107, the user must grant the `clipboard-write` permission.
- This method must be called within user gesture event handlers.
- Web extensions with the `clipboardWrite` permission in their manifest can write data without a user gesture.
- This method must be called within user gesture event handlers.
- From version 107, this method must be called within user gesture event handlers, or the user must grant the `clipboard-write` permission.
- Before version 107, the user must grant the `clipboard-write` permission.
- This method must be called within user gesture event handlers.
- This browser only partially implements this feature
- This feature was removed in a later browser version (133)
- This feature was removed in a later browser version (98)
- Only accepts a `Blob` or a Promise resolving to a `Blob` as the item data.
- Only accepts a `Blob` as the item data. See bug 40103226.
- This browser only partially implements this feature
- This feature was removed in a later browser version (133)
- This feature was removed in a later browser version (98)
- Only accepts a `Blob` or a Promise resolving to a `Blob` as the item data.
- Only accepts a `Blob` as the item data. See bug 40103226.
- This browser only partially implements this feature
- This feature was removed in a later browser version (98)
- The `ClipboardItem` constructor only accepts a blob as the item data, but not strings or Promises that resolve to strings or blobs. See bug 40103226.
Use cases
-
Using Async clipboard
The Clipboard interface of the Clipboard API provides read and write access to the contents of the system clipboard.
Cautions
- May not be supported in older browsers.
Implementation notes
- Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.