Clipboard.readText()

The Clipboard interface's readText() method returns a Promise which resolves with a copy of the textual contents of the system clipboard.

Syntax

var promise = navigator.clipboard.readText()

Parameters

None.

Return value

A Promise that resolves with a DOMString 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 DataTransfer objects representing the clipboard's contents.

To read non-text contents from the clipboard, use the read() method instead. You can write text to the clipboard using writeText().

Example

This example retrieves the textual contents of the clipboard and inserts the returned text into an element's contents.

navigator.clipboard.readText().then(
  clipText => document.getElementById("outbox").innerText = clipText);

Specifications

Specification Status Comment
Clipboard API and events
The definition of 'readText()' in that specification.
Working Draft Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 66Edge ? Firefox Full support 63
Notes
Full support 63
Notes
Notes Firefox only supports reading the clipboard in browser extensions, using the "clipboardRead" extension permission.
IE ? Opera Full support 53Safari ? WebView Android No support NoChrome Android Full support 66Edge Mobile ? Firefox Android Full support 63
Notes
Full support 63
Notes
Notes Firefox only supports reading the clipboard in browser extensions, using the "clipboardRead" extension permission.
Opera Android Full support 53Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

See also

Document Tags and Contributors

Contributors to this page: Sheppy, samouss, raghav710, lusbuab, ExE-Boss, jpmedley
Last updated by: Sheppy,