3 > Perform copy and paste operations on the system clipboard.
5 Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process)
7 The following example shows how to write a string to the clipboard:
10 const {clipboard} = require('electron')
11 clipboard.writeText('Example String')
14 On X Window systems, there is also a selection clipboard. To manipulate it
15 you need to pass `selection` to each method:
18 const {clipboard} = require('electron')
19 clipboard.writeText('Example String', 'selection')
20 console.log(clipboard.readText('selection'))
25 The `clipboard` module has the following methods:
27 **Note:** Experimental APIs are marked as such and could be removed in future.
29 ### `clipboard.readText([type])`
31 * `type` String (optional)
33 Returns `String` - The content in the clipboard as plain text.
35 ### `clipboard.writeText(text[, type])`
38 * `type` String (optional)
40 Writes the `text` into the clipboard as plain text.
42 ### `clipboard.readHTML([type])`
44 * `type` String (optional)
46 Returns `String` - The content in the clipboard as markup.
48 ### `clipboard.writeHTML(markup[, type])`
51 * `type` String (optional)
53 Writes `markup` to the clipboard.
55 ### `clipboard.readImage([type])`
57 * `type` String (optional)
59 Returns [`NativeImage`](native-image.md) - The image content in the clipboard.
61 ### `clipboard.writeImage(image[, type])`
63 * `image` [NativeImage](native-image.md)
64 * `type` String (optional)
66 Writes `image` to the clipboard.
68 ### `clipboard.readRTF([type])`
70 * `type` String (optional)
72 Returns `String` - The content in the clipboard as RTF.
74 ### `clipboard.writeRTF(text[, type])`
77 * `type` String (optional)
79 Writes the `text` into the clipboard in RTF.
81 ### `clipboard.readBookmark()` _macOS_ _Windows_
88 Returns an Object containing `title` and `url` keys representing the bookmark in
89 the clipboard. The `title` and `url` values will be empty strings when the
90 bookmark is unavailable.
92 ### `clipboard.writeBookmark(title, url[, type])` _macOS_ _Windows_
96 * `type` String (optional)
98 Writes the `title` and `url` into the clipboard as a bookmark.
100 **Note:** Most apps on Windows don't support pasting bookmarks into them so
101 you can use `clipboard.write` to write both a bookmark and fallback text to the
106 text: 'http://electron.atom.io',
107 bookmark: 'Electron Homepage'
111 ### `clipboard.readFindText()` _macOS_
113 Returns `String` - The text on the find pasteboard. This method uses synchronous
114 IPC when called from the renderer process. The cached value is reread from the
115 find pasteboard whenever the application is activated.
117 ### `clipboard.writeFindText(text)` _macOS_
121 Writes the `text` into the find pasteboard as plain text. This method uses
122 synchronous IPC when called from the renderer process.
124 ### `clipboard.clear([type])`
126 * `type` String (optional)
128 Clears the clipboard content.
130 ### `clipboard.availableFormats([type])`
132 * `type` String (optional)
134 Returns `String[]` - An array of supported formats for the clipboard `type`.
136 ### `clipboard.has(data[, type])` _Experimental_
139 * `type` String (optional)
141 Returns `Boolean` - Whether the clipboard supports the format of specified `data`.
144 const {clipboard} = require('electron')
145 console.log(clipboard.has('<p>selection</p>'))
148 ### `clipboard.read(data[, type])` _Experimental_
151 * `type` String (optional)
153 Returns `String` - Reads `data` from the clipboard.
155 ### `clipboard.write(data[, type])`
158 * `text` String (optional)
159 * `html` String (optional)
160 * `image` [NativeImage](native-image.md) (optional)
161 * `rtf` String (optional)
162 * `bookmark` String (optional) - The title of the url at `text`.
163 * `type` String (optional)
166 const {clipboard} = require('electron')
167 clipboard.write({text: 'test', html: '<b>test</b>'})
169 Writes `data` to the clipboard.