How to Set Up a System-Wide Word Count Service on Your Mac

by

In this article, we're going to show you how to create a system-wide service that enables you to get an immediate word count and character count in TextEdit, Safari, Mail, or indeed any app on your Mac that lets you highlight text. It offers a handy home-made solution if you often find yourself pasting into a blank Word or Pages document for no other reason than to find out how many words are in a text selection.

word count automator service 2
The steps below will guide you through the process of creating your own word count service using the macOS Automator app. It's a simple procedure to follow and should only take five minutes, but if you'd rather use a third-party solution, then check out WordCounter, a free Mac menu bar utility from Onekerato.

How to Create a Word Count Service in Automator

  1. Launch Automator from the Applications folder.
    1 Automator

  2. Click New Document.

  3. Choose Service as the type of your document.
    2 Automator document type

  4. Type "run" into the Library search field at the top of the Automator sidebar, then drag the Run Shell Script action into the empty workflow area.
    automator drag shell script

  5. In the Run Shell Script action window, change the Pass Input: option to as arguments using the dropdown menu.
    automator run shell script

  6. Clear the text in the shell script box (highlight the text with your mouse cursor and hit Backspace) then copy and paste the following text into the same area:

    echo Words:

    echo $1 | wc -w

    echo Characters including spaces:

    echo $1 | wc -c
    automator word count script

  7. Clear the Library search field at the top of the Automator sidebar and type "set value", then drag the Set Value of Variable action into the workflow area.
    automator set value of variable

  8. Click the Variable: dropdown menu and select New Variable....

  9. In the blue dialog that appears, click inside the Name: input field. It may default to "storage", but you can rename it – we'll call it "count". Click Done, and you should now see "count" (or whichever name you used) appear in the variable list below the workflow area.
    automator variable name

  10. Clear the Library search field at the top of the Automator sidebar again, and this time type "ask", then drag the Ask for Confirmation action into the workflow area.
    drag ask for confirm

  11. Now, drag your "count" variable from the variable list up to the "Message" title in the Ask for Confirmation action.
    drag count variable

  12. In the Automator menu bar, select File -> Save..., call your new service "Word Count", and click Save.

Next time you want to get a word count and/or character count for some text you've highlighted, simply right-click (or Ctrl-click) on the text and select Services -> Word Count from the contextual dropdown menu.

word count
You can assign a key shortcut to it for even faster access. To do so, launch System Preferences, select the Keyboard pane, and click the Shortcuts tab. Select Services from the sidebar and you should find Word Count near the bottom of the list. Just click it, select Add Shortcut, and finally, enter your custom key combination.

word count shortcut

Top Rated Comments

TheralSadurns Avatar
33 months ago
Srsly guys... I don't think I'll need this. But you rock! Keep these guides and tutorials coming!!! They are MUCH appreciated!
Score: 11 Votes (Like | Disagree)
H2SO4 Avatar
33 months ago

Srsly guys... I don't think I'll need this. But you rock! Keep these guides and tutorials coming!!! They are MUCH appreciated!

Was gonna say exactly this till I saw your post. Reminds me of MacOXSHints.
[doublepost=1526030048][/doublepost]

Or get WordService for free from the App Store to give you text stats and so much more:
https://itunes.apple.com/app/wordservice/id899972312?mt=12

Maybe but this also teaches you stuff.
Score: 6 Votes (Like | Disagree)
IJ Reilly Avatar
33 months ago

Or get WordService for free from the App Store to give you text stats and so much more:
https://itunes.apple.com/app/wordservice/id899972312?mt=12

Beat me to it. I've used this indispensable collection of services for over 15 years. Can also be downloaded here:

https://www.macupdate.com/app/mac/10523/wordservice
[doublepost=1526061714][/doublepost]

Maybe but this also teaches you stuff.

I learned that I don't have to do it myself. ;)
Score: 2 Votes (Like | Disagree)
fairuz Avatar
33 months ago
Automator is one of the many amazing productivity features in macOS that few know about. It's saved me so much time.
Score: 2 Votes (Like | Disagree)
mingravity Avatar
33 months ago

Srsly guys... I don't think I'll need this. But you rock! Keep these guides and tutorials coming!!! They are MUCH appreciated!

absolutely !! very useful read
Score: 1 Votes (Like | Disagree)
MauiPa Avatar
33 months ago

Interesting, but all the text and code editors I use these days already have word and character counters built-in. Also, as stop-hammertime mentioned, if terminal commands aren't filtered, this script could execute code with unintended, or even dire consequences.

Padawan, perhaps it is the journey and not the destination.
Score: 1 Votes (Like | Disagree)

Top Stories

windows 10

Developer Successfully Virtualizes Windows for Arm on M1 Mac

Friday November 27, 2020 7:16 am PST by
Developer Alexander Graf has successfully virtualized the Arm version of Windows on an M1 Mac, proving that the M1 chip is capable of running Microsoft's operating system (via The 8-Bit). Currently, Macs with the M1 chip do not support Windows and there is no Boot Camp feature as there is on Intel Macs, but support for Windows is a feature that many users would like to see. Using the...
iPhone black friday 20 sale feature

Apple Black Friday 2020: Best iPhone Deals

Friday November 27, 2020 12:56 pm PST by
Black Friday is halfway done, but there are still a few deals to shop for on iPhones at carriers like AT&T, Verizon, and T-Mobile/Sprint. Note: MacRumors is an affiliate partner with some of these vendors. When you click a link and make a purchase, we may receive a small payment, which helps us keep the site running. AT&T Starting with AT&T, you'll find up to $700 off any iPhone 12 when...
AirPods Pro black friday 20 sale feature 2

Black Friday 2020: AirPods Pro Reach Lowest Price Ever [Updated]

Wednesday November 25, 2020 3:22 pm PST by
Black Friday has kicked off this week, and one of the first major sales for the AirPods Pro is available right now on Walmart. You can find this deal below, along with a few other solid discounts on the regular AirPods. Note: MacRumors is an affiliate partner with some of these vendors. When you click a link and make a purchase, we may receive a small payment, which helps us keep the site...
Apple Watc black friday 20 sale feature

Apple Black Friday 2020: Best Apple Watch Deals [Updated]

Wednesday November 25, 2020 4:01 pm PST by
Black Friday sales have begun on a variety of products, including the Apple Watch. There are quite a few deals across the Apple Watch lineup this year, including one of the lowest price we've ever seen the Apple Watch Series 3. Note: MacRumors is an affiliate partner with some of these vendors. When you click a link and make a purchase, we may receive a small payment, which helps us keep the...
iphone trade in store

UK Environmental Committee Says Apple Contributing to 'Throwaway Culture' of 'Short-Lived Products'

Thursday November 26, 2020 7:07 am PST by
Technology companies like Apple are contributing to e-waste by making their products difficult to repair, and charging expensive repair fees, according to a lengthy report published today by the UK Parliament's Environmental Audit Committee. "We were told that Apple glues and solders parts together on their laptops, which makes repairing them very difficult," the Committee wrote in a summary ...
MacBooks black friday

Apple Black Friday 2020: Best Mac and MacBook Deals

Thursday November 26, 2020 8:29 pm PST by
For Black Friday 2020, many retailers have solid deals on a variety of Macs. Apple's new M1 Macs are ones everyone wants right now, but because they're so new, deals on them are fairly sparse, although we are seeing some modest discounts. Note: MacRumors is an affiliate partner with some of these vendors. When you click a link and make a purchase, we may receive a small payment, which helps...
Top Stories 38 Feature

Top Stories: Black Friday Deals, Redesigned MacBooks, Hands-On With Apple's M1 Macs

Saturday November 28, 2020 6:00 am PST by
With Apple's holiday hardware lineup seemingly all set, attention this week turned to the shopping end of things with Apple and other retailers rolling out their Black Friday deals. That wasn't the only news this week, however, as we've continued to learn more about Apple's new M1-based Macs and we've even heard some fresh rumors about redesigned Mac notebooks coming next year, so read on...
General black friday 20 sale feature 2

Apple Black Friday 2020: Our Top Picks

Friday November 27, 2020 6:16 am PST by
Black Friday shopping has officially kicked off across the United States, and we've been collecting the best deals for Apple's iPads, Macs, AirPods, the HomePod, Apple Watch, and more in separate articles. In order to further streamline your Black Friday shopping this year, we've put together this quick list of our top picks of the overall best Apple-related bargains happening today. Note:...
mac mini macbook pro macbook air

Apple M1 Hands-On Comparison: MacBook Air vs. MacBook Pro vs. Mac Mini

Monday November 23, 2020 3:40 pm PST by
Apple's M1 Macs are out in the wild now, but ahead of the holidays, you might still be trying to figure out which one to pick up, either for yourself or as a gift for someone else. We've got all three of the new Macs available, so we thought we'd give MacRumors readers a hands-on overview of each machine in our latest YouTube video. Subscribe to the MacRumors YouTube channel for more videos. ...
General black friday 20 sale feature

Thanksgiving Day Deals Still Available on AirPods, M1 Macs, Apple Watch Series 6, iPads

Thursday November 26, 2020 10:21 am PST by
Black Friday deals seem to start earlier and earlier every year, so there were already a wide variety of discounts available for Apple products on Thanksgiving Day. Many of the deals remain available even after Thanksgiving, but act fast, as inventory quickly fluctuates. Thanksgiving Day Deals on Apple Products — Still Available:AirPods with a wireless charging case remain available for...