twitter /twemoji
Emoji for everyone. https://twemoji.twitter.com/
★ 17,818⑂ 1,890👁 325⑃ 199● 460▤ 31
-1
日增长
+3
周增长
+17
月增长
17,818
stars
1,890
forks
325
watchers
199
prs
460
issues
31
releases
README
Twitter Emoji (Twemoji)
A simple library that provides standard Unicode emoji support across all platforms.
Twemoji v14.0 adheres to the Unicode 14.0 spec and supports the Emoji 14.0 spec. _We do not support custom emoji._
The Twemoji library offers support for all Unicode-defined emoji which are recommended for general interchange (RGI).
Usage
CDN Support
The folks over at MaxCDN have graciously provided CDN support.
MaxCDN is shut down right now, so in the meanwhile use a different CDN or download the assets. (See Maxcdn has shut down, cdn not working anymore. · Issue 580 · twitter/twemoji).
Use the following in the tag of your HTML document(s):
html
This guarantees that you will always use the latest version of the library.
If, instead, you'd like to include the latest version explicitly, you can add the following tag:
html
Download
If instead you want to download a specific version, please look at the gh-pages branch, where you will find the built assets for both our latest and older versions.
API
Following are all the methods exposed in the twemoji namespace.
twemoji.parse( ... ) V1
This is the main parsing utility and has 3 overloads per parsing type.
Although there are two kinds of parsing supported by this utility, we recommend you use DOM parsing, explained below. Each type of parsing accepts a callback to generate an image source or an options object with parsing info.
The second kind of parsing is string parsing, explained in the legacy documentation here. This is unrecommended because this method does not sanitize the string or otherwise prevent malicious code from being executed; such sanitization is out of scope.
DOM parsing
If the first argument to twemoji.parse is an HTMLElement, generated image tags will replace emoji that are inside text nodes only without compromising surrounding nodes or listeners, and completely avoiding the usage of innerHTML.
If security is a major concern, this parsing can be considered the safest option but with a slight performance penalty due to DOM operations that are inevitably costly.
js
var div = document.createElement('div');
div.textContent = 'I \u2764\uFE0F emoji!';
document.body.appendChild(div);
twemoji.parse(document.body);
var img = div.querySelector('img');
// note the div is preserved
img.parentNode === div; // true
img.src; // https://twemoji.maxcdn.com/v/latest/72x72/2764.png
img.alt; // \u2764\uFE0F
img.className; // emoji
img.draggable; // false
All other overloads described for string are available in exactly the same way for DOM parsing.
Object as parameter
Here's the list of properties accepted by the optional object that can be passed to the parse function.
js
{
callback: Function, // default the common replacer
attributes: Function, // default returns {}
base: string, // default MaxCDN
ext: string, // default ".png"
className: string, // default "emoji"
size: string|number,Top issues
#1457Fix issue where obsolete flag is used for the Islamic Republic Of Iran23 comments · 2026-01-10#1451🇮🇷 Wait until the coup is over before you apply new Israel-backed flag21 comments · 2026-01-09#138Port twemoji 2.0 to Java13 comments · 2016-04-06#570Add support for Unicode/Emoji 15.012 comments · 2022-10-31#1462Syrian flag emoji is outdated / inconsistent across platforms11 comments · 2026-02-02#615Where is the donkey, goose, jellyfish and moose?10 comments · 2023-05-27#590@chinanws2210 comments · 2023-02-13#641twemoji.twitter.com no longer acceccible8 comments · 2024-06-05
Latest release
Twemoji 14.0.2 update v14.0.2 2022-03-31More TypeScript type definition fixes (541). Oh, TypeScript. Thanks @Saul-Mirone! Full Changelog: https://github.com/twitter/twemoji/compare/v14.0.1...v14.0.2