ClipboardItem: ClipboardItem() constructor

Baseline 2025
Newly available

Since February 2025, 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 ClipboardItem() constructor creates a new ClipboardItem object, which represents data to be stored or retrieved via the Clipboard API clipboard.write() and clipboard.read() methods, respectively.

Note: The read() and write() methods can be used to work with text strings and arbitrary data items represented by Blob instances. However, if you are solely working with text, it is more convenient to use the Clipboard.readText() and Clipboard.writeText() methods.

Note: Image format support varies by browser. See the browser compatibility table for the Clipboard interface.

Syntax

js
new ClipboardItem(data)
new ClipboardItem(data, options)

Parameters

data

An Object with the MIME type as the key and data as the value. The data can be represented as one of the following:

  • a Blob
  • a string
  • a Promise that resolves to either a Blob or string.
options Optional

An object with the following properties:

presentationStyle Optional

One of the three strings: unspecified, inline or attachment. The default is unspecified.

inline signifies to apps that receive the paste that the ClipboardItem should be inserted inline at the point of paste. attachment signifies to apps that receive the paste that the ClipboardItem should be added as an attachment. unspecified doesn't signify any information to apps that receive the paste.

Examples

The below example requests a PNG image using fetch(), and in turn, the Response.blob() method, to create a new ClipboardItem. This item is then written to the clipboard, using the Clipboard.write() method.

Note: You can only pass in one clipboard item at a time.

js
async function writeClipImg() {
  try {
    if (ClipboardItem.supports("image/png")) {
      const imgURL = "/my-image.png";
      const data = await fetch(imgURL);
      const blob = await data.blob();
      await navigator.clipboard.write([
        new ClipboardItem({
          [blob.type]: blob,
        }),
      ]);
      console.log("Fetched image copied.");
    } else {
      console.log("image png is not supported");
    }
  } catch (err) {
    console.error(err.name, err.message);
  }
}

Specifications

Specification
Clipboard API and events
# dom-clipboarditem-clipboarditem

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
ClipboardItem() constructor
Chrome – Partial support
Chrome 76 – 97 (Release date: 2019-07-30)
footnote Partial support
footnote Only accepts a Blob as the item data. See bug 40103226.
Chrome – Partial support
Chrome 98 – 132 (Release date: 2022-02-01)
footnote Partial support
footnote Only accepts a Blob or a Promise resolving to a Blob as the item data.
Chrome – Full support
Chrome 133 (Release date: 2025-02-04)
footnote Full support
Edge – Partial support
Edge 79 – 97 (Release date: 2020-01-15)
footnote Partial support
footnote Only accepts a Blob as the item data. See bug 40103226.
Edge – Partial support
Edge 98 – 132 (Release date: 2022-02-03)
footnote Partial support
footnote Only accepts a Blob or a Promise resolving to a Blob as the item data.
Edge – Full support
Edge 133 (Release date: 2025-02-06)
footnote Full support
Firefox – Full support
Firefox 127 (Release date: 2024-06-11)
footnote Full support
Opera – Partial support
Opera 63 – 83 (Release date: 2019-08-20)
footnote Partial support
footnote Only accepts a Blob as the item data. See bug 40103226.
Opera – Partial support
Opera 84 – 117 (Release date: 2022-02-16)
footnote Partial support
footnote Only accepts a Blob or a Promise resolving to a Blob as the item data.
Opera – Full support
Opera 118 (Release date: 2025-04-15)
footnote Full support
Safari – Full support
Safari 13.1 (Release date: 2020-03-24)
footnote Full support
Chrome Android – Partial support
Chrome Android 84 – 97 (Release date: 2020-07-27)
footnote Partial support
footnote The ClipboardItem constructor only accepts a blob as the item data, but not strings or Promises that resolve to strings or blobs. See bug 40103226.
Chrome Android – Full support
Chrome Android 98 (Release date: 2022-02-01)
footnote Full support
Firefox for Android – Full support
Firefox for Android 127 (Release date: 2024-06-11)
footnote Full support
Opera Android – Partial support
Opera Android 60 – 67 (Release date: 2020-09-23)
footnote Partial support
footnote The ClipboardItem constructor only accepts a blob as the item data, but not strings or Promises that resolve to strings or blobs. See bug 40103226.
Opera Android – Full support
Opera Android 68 (Release date: 2022-03-30)
footnote Full support
Safari on iOS – Full support
Safari on iOS 13.4 (Release date: 2020-03-24)
footnote Full support
Samsung Internet – Partial support
Samsung Internet 14 – 17 (Release date: 2021-04-17)
footnote Partial support
footnote The ClipboardItem constructor only accepts a blob as the item data, but not strings or Promises that resolve to strings or blobs. See bug 40103226.
Samsung Internet – Full support
Samsung Internet 18 (Release date: 2022-08-08)
footnote Full support
WebView Android – Partial support
WebView Android 84 – 97 (Release date: 2020-07-27)
footnote Partial support
footnote The ClipboardItem constructor only accepts a blob as the item data, but not strings or Promises that resolve to strings or blobs. See bug 40103226.
WebView Android – Full support
WebView Android 98 (Release date: 2022-02-01)
footnote Full support
WebView on iOS – Full support
WebView on iOS 13.4 (Release date: 2020-03-24)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Has more compatibility info.

See also