Since April 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The readText() method of the Clipboard interface returns a Promise which fulfills with a copy of the textual contents of the system clipboard.
Note: To read non-text contents from the clipboard, use the read() method instead. You can write text to the clipboard using writeText().
readText()
None.
A Promise that resolves with a string containing the textual contents of the clipboard.
Returns an empty string if the clipboard is empty, does not contain text, or does not include a textual representation among the objects representing the clipboard's contents.
NotAllowedError DOMException
Thrown if the access to read the clipboard is not allowed.
NotFoundError DOMException
Thrown if the clipboard indicates that it contains data that can be represented as a text but is unable to provide a textual representation.
Reading from the clipboard can only be done in a secure context.
Additional security requirements are covered in the Security consideration section of the API overview topic.
This example retrieves the textual contents of the clipboard and inserts the returned text into a selected element's contents.
const destination = document.getElementById("outbox");
destinationImage.addEventListener("click", () => {
navigator.clipboard
.readText()
.then((clipText) => (destination.innerText = clipText));
});
| Specification |
|---|
| Clipboard API and events> # dom-clipboard-readtext> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
readText |
66The user must grant theclipboard-read permission. |
79The user must grant theclipboard-read permission. |
125["This method must be called within user gesture event handlers.", "Web extensions require theclipboardRead permission in manifest to read data. With this permission, the extension does not require a user interaction and does not display a paste prompt.", "A paste prompt is displayed when the clipboard is read. If the clipboard contains same-origin content, the prompt is suppressed."] |
53The user must grant theclipboard-read permission. |
13.1 | 66The user must grant theclipboard-read permission. |
125["This method must be called within user gesture event handlers.", "Web extensions require theclipboardRead permission in manifest to read data. With this permission, the extension does not require a user interaction and does not display a paste prompt.", "A paste prompt is displayed when the clipboard is read. If the clipboard contains same-origin content, the prompt is suppressed."] |
47The user must grant theclipboard-read permission. |
13.4 | 9.0The user must grant theclipboard-read permission. |
66The user must grant theclipboard-read permission. |
13.4 |
Clipboard.read()Clipboard.writeText()Clipboard.write()
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/readText