Clipboard API

The Clipboard API provides the ability to respond to clipboard commands (cut, copy, and paste) as well as to asynchronously read from and write to the system clipboard.

Note: This API is not available in Web Workers (not exposed via WorkerNavigator).

This API is designed to supersede accessing the clipboard using document.execCommand().

Accessing the clipboard

Instead of creating a Clipboard object through instantiation, you access the system clipboard through the Navigator.clipboard global:

  clipText => document.querySelector(".editor").innerText += clipText);

This snippet fetches the text from the clipboard and appends it to the first element found with the class editor. Since readText() (and read(), for that matter) returns an empty string if the clipboard isn't text, this code is safe.


Clipboard Secure context

Provides an interface for reading and writing text and data to or from the system clipboard. The specification refers to this as the 'Async Clipboard API.'

ClipboardEvent Secure context

Represents events providing information related to modification of the clipboard, that is cut, copy, and paste events. The specification refers to this as the 'Clipboard Event API'.

ClipboardItem Secure context

Represents a single item format, used when reading or writing data.


Clipboard API and events
# clipboard-interface
Clipboard API and events
# clipboard-event-interfaces
Clipboard API and events
# clipboarditem

Browser compatibility


BCD tables only load in the browser


BCD tables only load in the browser


BCD tables only load in the browser

See also