smile2emoji is a simple-to-use JavaScript library that converts text emoticons like :), ^^, :blush: and even Unicode strings into their corresponding emoji images (😊).
It can scan text for emoticon patterns and replace them with emoji. This can help make conversations and content more visual and expressive.
How
to use it:
1. Install the smile2emoji with NPM.
# NPM $ npm i smile2emoji
2. The library exports four easy-to-use functions for converting text, detecting emoji patterns, and more. The main checkText() function scans a string for any defined emoticon patterns like :) or ^^ and replaces them with the corresponding emoji.
import { checkText } from 'smile2emoji'
// OR from a CDN
import { checkText } from "https://cdn.skypack.dev/smile2emoji";
const emoji = checkText(':)');
3. The fromUnicodeToEmoji() is a specialized function that directly translates Unicode to emojis
import { fromUnicodeToEmoji } from 'smile2emoji'
// OR from a CDN
import { fromUnicodeToEmoji } from "https://cdn.skypack.dev/smile2emoji";
// ☁️
const emoji = fromUnicodeToEmoji('2601');
4. The checkTextWithAutoSuggestions() and checkTextWithAutoSuggestionsAndUnicode() functions detect emoji syntax and replace it with the appropriate emoji even if it’s not an exact match.
import { checkTextWithAutoSuggestions } from 'smile2emoji'
import { checkTextWithAutoSuggestionsAndUnicode } from 'smile2emoji'
// OR from a CDN
import { checkTextWithAutoSuggestions } from "https://cdn.skypack.dev/smile2emoji";
import { checkTextWithAutoSuggestionsAndUnicode } from "https://cdn.skypack.dev/smile2emoji";
// 🎾
emoji = checkTextWithAutoSuggestions(':tenn');
// 🎾
emoji = checkTextWithAutoSuggestionsAndUnicode(':tenn');
Changelog:
v3.17.2 (04/21/2025)
- bugfix
v3.17.1 (02/15/2025)
- update
v3.17.0 (12/14/2024)
- update
v3.15.0/1 (10/09/2024)
- update
v3.14.0 (10/03/2024)
- update
v3.13.0 (07/09/2024)
- update
v3.12.0 (06/02/2024)
- update
v3.11.0 (03/02/2024)
- update
v3.10.0 (02/04/2024)
- release: package updated + produce esm output
v3.9.1 (01/31/2024)
- Bugfix
v3.9.0 (12/28/2023)
- commonjs: now the project is common js – chai 5 works
- release-config: changed from .js to .cjs
The post Convert Text Emoticons to Emoji – smile2emoji appeared first on CSS Script.
Discover more from RSS Feeds Cloud
Subscribe to get the latest posts sent to your email.
