The Clipboard interface's writeText() property writes the specified text string to the system clipboard. Text may be read back using either read() or readText().

The "clipboard-write" permission of the Permissions API, is granted automatically to pages when they are in the active tab.


var promise = navigator.clipboard.writeText(newClipText)


The DOMString to be written to the clipboard.

Return value

A Promise which is resolved once the clipboard's contents have been updated. The promise is rejected if the caller does not have permission to write to the clipboard.


This example sets the clipboard's contents to the string "<empty clipboard>".

navigator.clipboard.writeText("<empty clipboard>").then(function() {
  /* clipboard successfully set */
}, function() {
  /* clipboard write failed */


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

Browser compatibility

BCD tables only load in the browser

See also