files/en-us/web/api/clipboard/readtext/index.md
{{APIRef("Clipboard API")}} {{securecontext_header}}
The readText() method of the {{domxref("Clipboard")}} interface returns a {{jsxref("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 {{domxref("Clipboard.read", "read()")}} method instead. You can write text to the clipboard using {{domxref("Clipboard.writeText", "writeText()")}}.
readText()
None.
A {{jsxref("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 {{domxref("DOMException")}}
NotFoundError {{domxref("DOMException")}}
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));
});
{{Specifications}}
{{Compat}}