Skip to content

API in Capabilities

ClipboardItem

Published Updated

Newly available since 2024-06W3C draft

The ClipboardItem interface packages clipboard data as one or more MIME representations. Pass an item to navigator.clipboard.write(), or receive items from navigator.clipboard.read(), then inspect types and retrieve a representation with getType() (Clipboard API and events, W3C).

ClipboardItem is available in secure contexts. BCD api.ClipboardItem records the interface from Chrome 76, Chrome for Android 84, Firefox 127, and Safari 13.1. The Async Clipboard compatibility data shows the related read and write surface. MDN marks ClipboardItem as Baseline 2024 while noting that individual parts have different support (ClipboardItem, MDN).

const item = new ClipboardItem(items);
const styledItem = new ClipboardItem(items, options);
item.types;
item.presentationStyle;
await item.getType(type);
ClipboardItem.supports(type);

The constructor accepts a record whose keys are MIME types and whose values are strings, Blob objects, or promises for either form. The specification exposes ClipboardItem on Window, not workers. An item returned by navigator.clipboard.read() lists formats in types; the specification fetches the bytes when getType() runs and shares an in-flight read between concurrent calls for the same type.

Member Type Meaning
options.presentationStyle "unspecified", "inline", or "attachment" Optional presentation hint; the default is "unspecified".
types Frozen array of strings MIME types represented by the item.
presentationStyle String The presentation hint stored on the item.
getType(type) Promise<Blob> Retrieves the blob for a represented MIME type.
supports(type) Boolean Reports whether the browser supports a MIME type for clipboard writing.

The specification distinguishes a constructed item from an item returned by read(). Constructed values already hold the supplied representation promises. A read item acts as a lazy fetcher: its types reflect the formats present when read() ran, while getType() requests the selected payload. If the system clipboard changes before that request, the specification rejects the call with InvalidStateError.

ClipboardItem.supports() is synchronous. Use it to decide whether to add an optional representation, but still keep a representation that the receiving application can use. MDN documents types and presentationStyle as read-only properties and getType() as the method that returns the requested representation as a blob (ClipboardItem, MDN).

presentationStyle supplies a presentation hint to the paste destination. The specification defines "unspecified", "inline", and "attachment", with "unspecified" as the default. The hint does not replace format selection: a reader still chooses a representation from types. supports(type) serves a different purpose. The specification returns true when the type is among its mandatory or optional data types and returns false otherwise (Clipboard API and events, W3C).

For a text-only task, MDN recommends the convenience methods readText() and writeText() instead of the general read() and write() methods. ClipboardItem is the form used when read() or write() carries strings or arbitrary data represented by Blob objects. Its constructor accepts one or more MIME type keys and the corresponding data values, so one item can make separate representations available to the receiving application (ClipboardItem, MDN).

The constructor preserves the record’s representation order in types. WebKit documents why that order matters on macOS and iOS: it writes types to the system pasteboard in the supplied order, and native applications may treat earlier types as higher-fidelity choices (Async Clipboard API, WebKit). Put the representation that best preserves the copied content first, followed by formats that more paste targets can consume. A rich-text item can therefore list text/html before text/plain while still giving a plain-text editor usable data.

Each value may defer work with a promise. The web.dev clipboard article recommends starting asynchronous preparation inside the promise supplied to ClipboardItem for Safari, instead of awaiting the preparation before constructing the item (Unblocking clipboard access, web.dev). This keeps the write() call in the user-activation handler while the representation finishes. The promise must still resolve to a string or Blob accepted by the constructor; a rejected representation promise makes the clipboard write fail under the specification’s write algorithm.

The constructor also normalizes MIME type keys before storing them. The specification throws TypeError for an empty items record, a key that cannot be parsed as a MIME type, or a duplicate representation with the same parsed type and custom-format flag. A standard text/html representation and a web text/html custom representation do not collide because the latter retains its custom flag. These checks happen when the item is constructed, before it is passed to navigator.clipboard.write() (Clipboard API and events, W3C).

The constructor validates the representation record and MIME type strings. The Clipboard specification requires getType() to throw TypeError when its argument cannot be parsed as a MIME type. When the type is valid but the item has no matching representation, the returned promise rejects with NotFoundError. The specification also defines InvalidStateError for a read item whose source clipboard has changed (Clipboard API and events, W3C).

The examples use a click handler because clipboard writes are permission-sensitive. Each branch updates visible status text so the reader can tell whether the rich or fallback path ran.

Writing HTML with a plain-text representation

Section titled “Writing HTML with a plain-text representation”

Package HTML and plain text in the same item. If the rich clipboard surface is absent, use writeText(); if that method is also absent, select a textarea and ask execCommand("copy") to copy plain text.

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>ClipboardItem example</title>
<button id="copy" type="button">Copy the OpenPWA card</button>
<output id="status" aria-live="polite"></output>
<script>
async function copyCard(html, text, status) {
if (navigator.clipboard?.write && "ClipboardItem" in window) {
const item = new ClipboardItem({
"text/html": new Blob([html], { type: "text/html" }),
"text/plain": new Blob([text], { type: "text/plain" }),
});
await navigator.clipboard.write([item]);
status.textContent = "Copied HTML and plain text";
return;
}
if (navigator.clipboard?.writeText) {
await navigator.clipboard.writeText(text);
status.textContent = "Copied plain text";
return;
}
const area = Object.assign(document.createElement("textarea"), { value: text });
document.body.append(area);
area.select();
status.textContent = document.execCommand("copy") ? "Copied plain text" : "Copy failed";
area.remove();
}
document.querySelector("#copy").addEventListener("click", () =>
copyCard("<strong>OpenPWA</strong>", "OpenPWA", document.querySelector("#status")),
);
</script>
</html>

The web.dev clipboard article documents execCommand() as the older DOM-bound route and shows multiple MIME representations in one ClipboardItem (Unblocking clipboard access, web.dev). The fallback above preserves the plain-text task without claiming rich-format support.

Reading an image and handling a missing representation

Section titled “Reading an image and handling a missing representation”

Check the API and the item’s advertised types before requesting bytes. This failure path focuses a paste target when direct clipboard reading is unavailable, denied, or contains no PNG.

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Paste a PNG</title>
<button id="paste" type="button">Read PNG from clipboard</button>
<output id="status" aria-live="polite"></output>
<img id="preview" alt="Pasted PNG preview" hidden>
<div id="paste-target" contenteditable="true" role="textbox" tabindex="0"
aria-label="Manual paste target">Paste the image here when prompted.</div>
<script>
async function pastePng(preview, fallback, status) {
if (!navigator.clipboard?.read) {
fallback.focus();
status.textContent = "Paste the image into the focused field";
return;
}
try {
const items = await navigator.clipboard.read();
const item = items.find((entry) => entry.types.includes("image/png"));
if (!item) {
fallback.focus();
status.textContent = "Clipboard has no PNG; paste a supported value";
return;
}
const blob = await item.getType("image/png");
preview.src = URL.createObjectURL(blob);
preview.hidden = false;
status.textContent = "PNG loaded";
} catch (error) {
if (error.name !== "NotAllowedError") throw error;
fallback.focus();
status.textContent = "Clipboard access denied; paste manually";
}
}
document.querySelector("#paste").addEventListener("click", () =>
pastePng(document.querySelector("#preview"), document.querySelector("#paste-target"), document.querySelector("#status")),
);
</script>
</html>

The W3C algorithm defines lazy retrieval for items returned by read(). The code requests only the advertised image/png representation and leaves a concrete manual-paste route for the other branches.

Specifications

SpecificationStatus
Async Clipboard APIW3C draft
Clipboard API and events: ClipboardItem interfaceW3C
  • Legend
  • Yes
  • Partial
  • Flag
  • No
  • Unknown
Browser / PlatformSupportVersionsConfidenceSourceNotes
Chrome (Desktop)#Yes76highsource1
Chrome (Android)#Yes76highsource23
Edge (Desktop)#Yes79highsource45
Firefox (Desktop)#Yes127highsource678
Firefox (Android)#Yes127highsource9101112
Safari (macOS)#Yes13.1highsource—
Safari (iOS)#Yes13.4highsource13
Samsung Internet#Yes12.0highsource1415
WebView (Android)#Yes76highsource1617
  1. The user must grant the `clipboard-read` permission.
  2. The user must grant the `clipboard-read` permission.
  3. Derived by browser-compat-data mirroring from Chrome.
  4. The user must grant the `clipboard-read` permission.
  5. Derived by browser-compat-data mirroring from Chrome.
  6. This method must be called within user gesture event handlers.
  7. A paste prompt is displayed when the clipboard is read. If the clipboard contains same-origin content, the prompt is suppressed.
  8. Web extensions with the `clipboardRead` permission in their manifest can read data without the paste prompt displaying. Prior to Firefox 147, extensions without this permission were unable to read clipboard data.
  9. This method must be called within user gesture event handlers.
  10. A paste prompt is displayed when the clipboard is read. If the clipboard contains same-origin content, the prompt is suppressed.
  11. Web extensions with the `clipboardRead` permission in their manifest can read data without the paste prompt displaying. Prior to Firefox 147, extensions without this permission were unable to read clipboard data.
  12. Derived by browser-compat-data mirroring from Firefox.
  13. Derived by browser-compat-data mirroring from Safari.
  14. The user must grant the `clipboard-read` permission.
  15. Derived by browser-compat-data mirroring from Chrome Android.
  16. The user must grant the `clipboard-read` permission.
  17. Derived by browser-compat-data mirroring from Chrome Android.

Source data: /compatibility/clipboard.json · Global usage: 96 % (StatCounter 2026-09, CC BY-SA 4.0)

Source: spec · MDN · Last verified 2026-10-03 · Confidence: high (computed from sources)

Cite this table

Async Clipboard API compatibility data — OpenPWA · Verified 2026-10-03 · CC BY 4.0 · JSON

When reusing compatibility data, keep the attribution, identify your changes and check each row’s original source. This citation excludes market-share and reach figures, which use CC BY-SA 4.0.