Emoji codes for Mac and iPad
Have you ever wished you could use Slack-style emoji codes like
:facepalm: in other apps on your Mac or iPad?
Wish no more!
TL;DR download emojicodes.plist to your Mac, and follow the “Import text replacements” macOS User Guide to add over 1800 emoji codes like
:sparkles:✨ and many more to your text replacement dictionary.
Wanna know how the sausage was made? Keep reading…
What is an emoji code? ¶
If you weren’t already using a chat service like Slack before the pandemic, there’s a good chance that you are now.
If not Slack, then perhaps Microsoft Teams, or Google Chat.
And if you didn’t already know the names of some of your favorite emoji — such as the “sweat_smile” 😅 — there’s a good chance you’ve started learning them while chatting at work, thanks to “emoji codes”.
An emoji code is the codename of an emoji, wrapped in colons (e.g.
:sweat_smile:). Many popular apps will automatically convert emoji codes to the actual emoji character.
Why use emoji codes? ¶
To save time of course. Who wants to pause from typing out a witty joke in an active Slack conversation to lift their hands from the keyboard, reach for the mouse or trackpad, click on the emoji selector, and then (finally!) browse for an emoji like a Neanderthal? By then the timing of the joke is probably ruined and everyone has already wandered off to refresh their coffee. In the absolute worst case scenario you could end up in a classic “jerk store” moment. Ain’t nobody got time for that!
The thing is, as soon as you start using emoji codes at work, it’s only a matter of time before you type out an emoji code in an app that doesn’t support them, and suddenly you’re in sadtrombone.com town.
Emoji codes aren’t built into the system (yet), so when you go to send an email or text message with a
:wave: or a
:thumbsup: you’ll just end up confusing the heck out of the spell checker, or at least tempting the autocomplete gods to duck it up. 😅
Let’s fix this.
Text replacement to the rescue ¶
One of my favorite built-in utilities that Apple provides is an out-of-the-box text replacement system1 on Mac, iPad, and iPhone.2
If you’re already using text replacement, then you can already guess where I’m headed with this.
If you only care about a handful of emoji codes you can easily add text replacement shortcuts to convert
:thumbsup: to 👍 and move on with your life.
That’s where I started, and even just a dozen or so emoji codes were enough to get me tweeting!
Lifehack! 💥 pic.twitter.com/agtu9Nc0P7— @[email protected] (@calebhailey) October 30, 2021
Here’s what it looks like in practice:
But then as soon as I started using emoji codes in other apps like iMessage and Mail.app, I kept trying emoji codes that I hadn’t added yet. Womp womp. So I started investigating how to add ALL OF THE EMOJI CODES, and here we are.
Putting it all together ¶
At this point we already know that text replacement does exactly what we need it to – it can replace any emoji code (e.g.
:scream:) with the corresponding emoji (e.g. 😱).
But there are hundreds of emoji — how could we add them all?
My first discovery was the excellent “Import text replacements” macOS User Guide, which provides three key ingredients:
- Synchronization. Your Mac, iPad, and iPhone text replacements are synced via iCloud, so “when you add a text replacement on your Mac, it appears automatically on your other devices (and vice versa).” This means we can do the heavy lifting on the Mac and things should “just work” on the iPad and iPhone. ✅
- Backup and restore. You can backup and restore (export and import) your existing text replacement rules, so we can experiment without fear of breaking things. 👌
- An API! (sort of)
Text replacement rules have an interchange format (a property list), so we can generate the data in this format instead of having to manually input
dozenshundreds of emoji codes.
With these key building blocks in hand I set out to generate a property list file that I could import into my text replacement rules on the Mac. I’m not a software engineer by trade, but I know enough to be dangerous in a handful of programming languages, so I started looking for the right tool for the job – ideally involving a robust standard library for XML.
My career in tech started around the end of the XML era. I’m vaguely familiar with the concepts, but everything I know about XML just makes me glad that JSON exists. 😅 Fortunately I had a working reference – an export of a relatively small number of emoji code text replacement rules – so I started from there.
Each text replacement rule is structured like this:
<dict> <key>phrase</key> <string>&#x1f6eb;</string> <key>shortcut</key> <string>:flight_departure:</string> </dict>
A text replacement has a “shortcut” (the emoji code) and the resulting “phrase” (a unicode character code representation of the emoji). Where could I source an exhaustive list of emoji codes and their unicode representations? The GitHub Emojis API! 3
Between the Golang
encoding/xml standard library, the GitHub Emojis API, and a little bit of elbow grease I was able to produce some highly questionable Go code that can generate text replacement rules for hundreds of emoji in a matter of seconds! 🙌
code hack on GitHub, or just download the resulting emojicodes.plist to your Mac, and follow the “Import text replacements” macOS User Guide to add over 1800 emoji codes like
:sparkles: ✨ and many more to your text replacement dictionary.
I hope you enjoyed this post, and hope that every time you use an emoji code it makes you say “Sheesh!” 😅
I spent a few minutes trying to dig up authoritative references to exactly when text replacement came to Mac, iPad, and iPhone. There are plenty of breadcrumbs, but nothing conclusive, thus this footnote. The TL;DR is that Apple added “AutoText Shortcuts” to iOS 5 in 2011 (following the success of third-party apps like TextExpander), and the Mac has supported text substitution since at least as far back as 2010 under various names including “Symbol and Text Substitution”. ↩︎
I can’t say anything about text substitution that hasn’t already been written — from extensive guides to some genuinely funny pranks you can pull on your friends the next time they leave their phone unlocked and unattended (and you’re bored). If you aren’t already using text substitution just do yourself a favor and search “iPhone text replacement tricks” on YouTube and you’ll no longer wonder how people type the
¯\_(ツ)_/¯(shrug) emoticon on their phones. ↩︎