Copy pure text from clipboard using AppleScript

set the clipboard to is defined in Standard Additions. You don't need to enclose it in a tell application "Word" ...

set the clipboard to (the clipboard as text)

Old question, but I found that the existing answers do not completely convert the text to plain. They seem to set the font to Helvetica and the size to 12.

However, you can pipe pbpaste and pbcopy to really remove formatting.

In the Terminal:

$ pbpaste | pbcopy

As an AppleScript:

do shell script "pbpaste | pbcopy"

That's it.


You don't show how you're copying and pasting currently. It should be possible to use something like this, though:

tell application "Word"
    set theData to (the clipboard as text)
    set the clipboard to theData
end tell

That will obtain the plain text version of the clipboard data and then replace the clipboard contents (which contains HTML) with the plain text.

To bind the script to a function key, I recommend using Automator to make a service that runs your script and then use the Keyboard pane of System Preferences to assign a key. In fact, I suspect this whole task would be better as a service that receives the text as input rather than attempting to explicitly fetch it from the clipboard.