This tool allow parse unicode and emoji codes to html images using emojilib && Twemoji CDN
npm install universal-emoji-parserThis tool allow parse emojis char unicodes and shortcodes to html images using emojilib && Twemoji.
This allows emojis to be standard across browsers, and avoid compatibility issues.
Emojis Support:
- Twitter emojis
- GitHub emojis
- Slack emojis
- Discord emojis
- Google Chat emojis
- Microsoft Teams emojis
---




``javascript
npm install universal-emoji-parser --save
or
yarn add universal-emoji-parser
`
`javascript
// ES6 import
ā import uEmojiParser from 'universal-emoji-parser'
or
// CommonJS require
ā const uEmojiParser = require('universal-emoji-parser')
`
``
ā uEmojiParser.parse('š')
``
ā uEmojiParser.parse(':smiling_face_with_sunglasses:')
``
ā uEmojiParser.parse('š')
``
ā uEmojiParser.parse(':rocket:')
``
ā uEmojiParser.parse('Hello world! š :smiling_face_with_sunglasses: š :rocket:')
Hello world!
- DEFAULT EMOJI CDN => https://cdn.jsdelivr.net/gh/jdecked/twemoji@latest/assets/svg/
| Option Name | Type | Default | Description |
| :--------------- | :------ | :------------------ | :-------------------------------------------------------------------------------------------------------------------- |
| emojiCDN | string | DEFAULT EMOJI CDN | Allow customize the emojis CDN. The parseToHtml option should be true to apply this option. |true
| parseToHtml | boolean | | Parse emojis unicodes and shortcodes into html images. |false
| parseToUnicode | boolean | | Parse emojis shortcodes into unicodes. The option parseToHtml should be false to apply. |false
| parseToShortcode | boolean | | Parse emojis unicodes into shortcodes. The options parseToHtml and parseToUnicode should be false to apply. |
Using different values for options:
``
ā uEmojiParser.parse('š', {})
``
ā uEmojiParser.parse(':smiling_face_with_sunglasses:', { parseToHtml: true })
``
ā uEmojiParser.parse('Hello world! :smiling_face_with_sunglasses: :rocket:', { parseToHtml: false, parseToUnicode: true })
Hello world! š š
``
ā uEmojiParser.parse('Hello world! š š', { parseToHtml: false, parseToShortcode: true })
Hello world! :smiling_face_with_sunglasses: :rocket:
Using custom CDN
``
ā uEmojiParser.parse('Hello world! š š', { emojiCDN: "https://custom.emoji.cdn/gh/jdecked/twemoji@latest/assets/svg/" })
Hello world!
``
ā uEmojiParser.parse('Hello world! š š', { parseToHtml: true, emojiCDN: https://custom.emoji.cdn/gh/jdecked/twemoji@latest/assets/svg/ })
Hello world!
``
ā uEmojiParser.parse('Hello world! š š', { parseToHtml: false, emojiCDN: "https://custom.emoji.cdn/gh/jdecked/twemoji@latest/assets/svg/" })
Hello world! š š
``
ā uEmojiParser.parseToHtml('Hello world! š :smiling_face_with_sunglasses: š :rocket:')
Hello world!
``
ā uEmojiParser.parseToUnicode('Hello world! :smiling_face_with_sunglasses: :rocket:')
Hello world! š š
``
ā uEmojiParser.parseToShortcode('Hello world! š š')
Hello world! :smiling_face_with_sunglasses: :rocket:
You can get the entire emoji lib json data curated and processed to best match with shortcode keywords.
`javascript
// ES6 import
ā import { emojiLibJsonData } from 'universal-emoji-parser'
or
// CommonJS require
const uEmojiParser = require('universal-emoji-parser')
const { emojiLibJsonData } = uEmojiParser
`
`
ā Object.keys(emojiLibJsonData).length
1898
ā emojiLibJsonData[š¤£]
{
name: 'rolling on the floor laughing',
slug: 'rolling_on_the_floor_laughing',
group: 'Smileys & Emotion',
emoji_version: '3.0',
unicode_version: '3.0',
skin_tone_support: false,
char: 'š¤£',
keywords: [
'rolling_on_the_floor_laughing',
'rolling',
'floor',
'laughing',
'rofl'
]
}
ā emojiLibJsonData[š]
{
name: 'smiling face with sunglasses',
slug: 'smiling_face_with_sunglasses',
group: 'Smileys & Emotion',
emoji_version: '1.0',
unicode_version: '1.0',
skin_tone_support: false,
char: 'š',
keywords: [
'smiling_face_with_sunglasses',
'cool',
'summer',
'beach',
'sunglass'
]
}
`
To properly scale emojis to fit within their containing elements, you can apply these global CSS styles:
```
img.emoji {
height: 1em;
width: 1em;
margin: 0 0.05em 0 0.1em;
vertical-align: -0.1em;
}
DailyBot is an AI Assistant powered by ChatGPT that takes chat and collaboration to the next level helping to automate: daily standups, team check-ins, surveys, kudos, virtual watercooler, 1:1 intros, motivation tracking, chatops and more. Learn more.
Universal Emoji Parser is MIT licensed.