demo · v133

Multi-format clipboard builder

Compose a single ClipboardItem that ships text/plain, text/html, and image/png simultaneously — each entry can now be a string, a blob, or a promise resolving to either. Paste in any target app to see which format won.

preview text/plain

preview text/html

click the button. paste into a rich-text editor (e-mail, notes) to see HTML, or a code editor to see plain text.

the new shape

const item = new ClipboardItem({
  "text/plain":  promise(plainText),        // string OR Promise<string>
  "text/html":   promise(html),
  "image/png":   fetch("/chart.png").then(r => r.blob())
});
await navigator.clipboard.write([item]);

Before 133, each format had to be a Blob or a Promise; strings had to be wrapped in new Blob([str], { type }). The boilerplate was a constant footgun for the canonical case of putting both plain and html on the clipboard.

see also