> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rebind.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# rb.clipboard

> Read text from the clipboard and put text on it.

`rb.clipboard` reads the text on the clipboard and puts new text on it. A script
reaches for it to work on text the user copied, or to paste long or multi-line
text: setting the clipboard and sending the paste chord is more reliable than
typing.

**Needs:** the [`clipboard:read`](https://docs.rebind.gg/reference/sdk/modeline#scoped-permissions)
[permission](https://docs.rebind.gg/reference/sdk/modeline.md#permissions) for `get` and
`clipboard:write` for `set` in a script that declares permissions.

This script trims the whitespace around the copied text and puts the result
back on the clipboard:

```luau theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
-- rebind: min_sdk=3.9.0 name=example version=1.0.0 permissions=clipboard:read,clipboard:write
local text = rb.clipboard.get()
if text == nil then
  print("the clipboard holds no text")
  return
end

local trimmed = (text:gsub("^%s+", ""):gsub("%s+$", ""))
rb.clipboard.set(trimmed)
print("trimmed the clipboard to", #trimmed, "characters")
```

| Signature | Returns |
| - | - |
| `rb.clipboard.get() -> string?` | the clipboard text, or `nil` when it holds no text |
| `rb.clipboard.set(text: string) -> ()` | |

A denied call raises
`Clipboard.Get() requires 'clipboard:read' permission` (or `Set` and `write`).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.