Strip markup from macOS clipboard and return as plain text with a shortcut key
Would you like to copy and paste text without formatting? This article shows you how to create a service with Automator to convert the text on the clipboard to plain text by using a global shortcut key.
Here’s an example of default copy/paste behaviour in Powerpoint on the Mac. Notice how the first text field has the Comic Sans font and the second field the Monaco font.
- Select the text
- Copy text (
- Select another text field
- Paste (
As you see, both the text and the markup (font etc.) has been copied. The second field now also has the Comic Sans font. If you just want to copy the text (plain text), you can either choose Paste Special or use a plain text editor to strip the text from its layout. After pasting the text, the monaco font in the second field would still be there and it would look like this:
Convert to plain text
Some macOS apps have support for Paste and Match Style and some apps support things like Paste special. I wanted a solution that works the same in every app and without using secondary app. I found this command you can run in the terminal:
pbpaste | pbcopy
pbpastepastes text on the clipboard (pb from pasteboard) to what comes after the pipe.
pbcopycopies input back to the clipboard as plain text
Step by step solution
Here are all the steps necessary to convert the text on the clipboard to plain text with the press of a hotkey.
- Open Automater
- Create new Quick Action
- Search for Run Shell Script
- Drag Run Shell Script to grey area
- Set Workflow receives to
pbpaste | pbcopyin the script editor
- Save as
- Run the action to see if there are no errors
- Open an app (like powerpoint) and check if
StripClipboardMarkupappears under Services
- Open the systems Keyboard Settings
- Select App Shortcuts
- Click the + button
StripClipboardMarkupas Menu Title
- Choose a shortcut. I chose
[to cleanup my clipboard.
And that’s it! Copy text from any app you like.
v will paste it like always. And if you want to strip the markup, press
[ before pasting.