# clipboardy

> Access the system clipboard (copy/paste)

Latest version **5.3.2** (published 2026-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install clipboardy
pnpm add clipboardy
yarn add clipboardy
bun add clipboardy
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.3.2 |
| Published | 2026-07-23 |
| First published | 2016-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 6 |
| Unpacked size | 854.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1984 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | clipboard, copy, paste, copy-paste, pasteboard, read, write, pbcopy, clip, xclip, xsel |

## Links

- npm: https://www.npmjs.com/package/clipboardy
- Repository: https://github.com/sindresorhus/clipboardy
- Homepage: https://github.com/sindresorhus/clipboardy#readme
- Issues: https://github.com/sindresorhus/clipboardy/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/clipboardy

## Dependencies (6)

- [execa](https://npm.io/package/execa.md) ^9.6.1
- [is-wsl](https://npm.io/package/is-wsl.md) ^3.1.0
- [is64bit](https://npm.io/package/is64bit.md) ^2.0.0
- [is-wayland](https://npm.io/package/is-wayland.md) ^0.1.0
- [clipboard-image](https://npm.io/package/clipboard-image.md) ^0.1.0
- [powershell-utils](https://npm.io/package/powershell-utils.md) ^0.2.0

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 5.3.2 (latest) — 2026-07-23
- 5.3.1 — 2026-02-24
- 5.3.0 — 2026-02-12
- 5.2.1 — 2026-02-03
- 5.2.0 — 2026-02-02
- 5.1.0 — 2026-01-25
- 5.0.2 — 2025-12-12
- 5.0.1 — 2025-11-20
- 5.0.0 — 2025-09-26
- 4.0.0 — 2023-10-23
- 3.0.0 — 2021-10-13
- 2.3.0 — 2020-03-19
- 2.2.0 — 2020-02-12
- 2.1.0 — 2019-06-15
- 2.0.0 — 2019-04-09
- … 15 more at https://npm.io/package/clipboardy/versions

## README

# clipboardy

> Access the system clipboard (copy/paste)

Cross-platform. Supports: macOS, Windows, Linux (including Wayland), OpenBSD, FreeBSD, Android with [Termux](https://termux.com/), and [modern browsers](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API#Browser_compatibility).

## Install

```sh
npm install clipboardy
```

## Usage

```js
import clipboard from 'clipboardy';

await clipboard.write('🦄');

await clipboard.read();
//=> '🦄'

// Or use the synchronous API
clipboard.writeSync('🦄');

clipboard.readSync();
//=> '🦄'
```

## API

**Browser usage:** Requires a [secure context](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts) (HTTPS). Synchronous methods are not available in browsers.

### clipboard

#### .write(text)

Write (copy) to the clipboard asynchronously.

Returns a `Promise<void>`.

##### text

Type: `string`

The text to write to the clipboard.

```js
await clipboard.write('🦄');
```

#### .read()

Read (paste) from the clipboard asynchronously.

Returns a `Promise<string>`.

```js
const content = await clipboard.read();
//=> '🦄'
```

#### .writeSync(text)

Write (copy) to the clipboard synchronously.

**Doesn't work in browsers.**

##### text

Type: `string`

The text to write to the clipboard.

```js
clipboard.writeSync('🦄');
```

#### .readSync()

Read (paste) from the clipboard synchronously.

Returns a `string`.

**Doesn't work in browsers.**

```js
const content = clipboard.readSync();
//=> '🦄'
```

#### .writeImages(filePaths)

Write (copy) images to the clipboard asynchronously.

Returns a `Promise<void>`.

**Only supported on macOS.** On other platforms, this is a no-op.

##### filePaths

Type: `string[]`

The file paths of the images to write to the clipboard. Supports any image type that macOS supports, including PNG, JPEG, HEIC, WebP, and GIF.

```js
await clipboard.writeImages(['/path/to/image.png']);
```

#### .readImages()

Read images from the clipboard asynchronously.

Returns a `Promise<string[]>` with file paths to temporary PNG files. You are responsible for cleaning up the files.

**Only supported on macOS.** On other platforms, this returns an empty array.

```js
const filePaths = await clipboard.readImages();
```

#### .hasImages()

Check if the clipboard contains images.

Returns a `Promise<boolean>`.

**Only supported on macOS.** On other platforms, this returns `false`.

```js
const hasImages = await clipboard.hasImages();
```

## FAQ

#### Does this work in headless Linux environments?

No. Clipboard operations on Linux require a display server (X11 or Wayland). Headless environments like CI servers or Raspberry Pi without a desktop environment do not have a system clipboard.

#### Where can I find the source of the bundled binaries?

The [Linux binary](fallbacks/linux/xsel) is just a bundled version of [`xsel`](https://linux.die.net/man/1/xsel). The source for the [Windows binary](fallbacks/windows/clipboard_x86_64.exe) can be found [here](https://github.com/sindresorhus/win-clipboard).

On Windows, clipboardy first tries the native PowerShell cmdlets (`Set-Clipboard`/`Get-Clipboard`) and falls back to the bundled binary if PowerShell is unavailable or restricted.

#### Does this work on Wayland?

Yes. On Linux, clipboardy automatically detects Wayland sessions and uses [`wl-clipboard`](https://github.com/bugaevc/wl-clipboard) when available. If not, it gracefully falls back to X11 tools. Also works with WSLg (Windows Subsystem for Linux GUI). Install `wl-clipboard` using your distribution's package manager.

## Related

- [clipboard-cli](https://github.com/sindresorhus/clipboard-cli) - CLI for this module
- [clipboard-image](https://github.com/sindresorhus/clipboard-image) - Get and set images on the clipboard
- [copy-text-to-clipboard](https://github.com/sindresorhus/copy-text-to-clipboard) - Copy text to the clipboard in the browser

---
_Source: https://npm.io/package/clipboardy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
