The Utility protocol:

protocol Utility {
  func openURL(_ string: String)
  func viewInOKJSON(_ string: String)
  func copyString(_ string: String)
  func getClipboardText() -> String
  func paste()



Open URL with default configuration. The URL can be an HTTP link or a URL Scheme.


let string = `
{"hello": "world"}

View JSON string in OK JSON.


$utility.copyString('OK JSON');

Copy string to clipboard.


let text = $utility.getClipboardText();

Get text from clipboard.

If your clipboard contains a path to a text file, $utility.getClipboardText will read the file and return the file content instead.


$utility.copyString('OK JSON');

Paste the clipboard content to the frontmost app.

Only works when OK JSON is not frontmost. For example, when run script from the Raycast extension.

You can combine $utility.paste with $file.copy to paste the result file in Finder.

let path = '/markdown/hello-world.md';

For $utility.paste to work, Accessibility permission is required for OK JSON.

To permit, go to System SettingsPrivacy & SecurityAccessibility or click here.