--- url: "https://web.dev/articles/clipboard/copy-images" titulek: "How to copy images | Clipboard | web.dev" h1: "How to copy images Stay organized with collections Save and categorize content based on your preferences." popis: "" jazyk: "en" kanonicka: "https://web.dev/articles/clipboard/copy-images" drobecky: ["Clipboard", "How to copy images"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 02:42:07" znaku: 3948 slov: 468 kodovani: "iso-8859-2" sha256: "065b5ccb7e81aa3b798492e0315d2e0edcd89faf34302ba54519b9530c370edd" --- How to copy images Stay organized with collections Save and categorize content based on your preferences. Thomas Steiner Many modern browsers support copying images to the clipboard in the formats PNG and SVG. Other formats are not yet supported for security reasons. The modern way Using the Async Clipboard API The [`Clipboard.write()`](/articles/clipboard/copy-images/%E2%80%8B%E2%80%8Bhttps:/developer.mozilla.org/docs/Web/API/Clipboard/write) method takes an array of [`ClipboardItem`](https://developer.mozilla.org/docs/Web/API/ClipboardItem) objects and returns a Promise that resolves when the image is successfully written to the clipboard. `Clipboard.write()` can only be used from the `window` object that has focus. Browser Support 76 79 127 13.1 [Source](https://developer.mozilla.org/docs/Web/API/Clipboard/write) The classic way Using `navigator.clipboard.writeText()` While not all browsers support `navigator.clipboard.write()` for binary data yet, they all support `navigator.clipboard.writeText()`. If you want to copy an SVG image, instead of copying the image itself, you can copy the SVG source code. For PNG images, you are unfortunately out of luck. Browser Support 66 79 63 13.1 [Source](https://developer.mozilla.org/docs/Web/API/Clipboard/writeText) Progressive enhancement `const button = document.querySelector('button'); const img = document.querySelector('img'); button.addEventListener('click', async () => { const responsePromise = fetch(img.src); try { if ('write' in navigator.clipboard) { await navigator.clipboard.write([ new ClipboardItem({ 'image/svg+xml': new Promise(async (resolve) => { const blob = await responsePromise.then(response => response.blob()); resolve(blob); }), }), ]); // Image copied as image. } else { const text = await responsePromise.then(response => response.text()); await navigator.clipboard.writeText(text); // Image copied as source code. } } catch (err) { console.error(err.name, err.message); } });` Further reading [Unblocking clipboard access](/async-clipboard) Demo HTML `