Categories: CSSScriptWeb Design

Convert Text Emoticons to Emoji – smile2emoji

In the world of digital communication, emojis have become a universal language, adding color and emotion to our texts.

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.

Table of Contents

Toggle

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.

rssfeeds-admin

Share
Published by
rssfeeds-admin

Recent Posts

Flawed Victory: The Long Road to a Good Mortal Kombat Movie Sequel

Since its release in 1997, Mortal Kombat: Annihilation’s place in the annals of video game…

2 seconds ago

Grown Ups 3 Is Officially in the Works at Netflix With Adam Sandler Returning

Netflix has confirmed that it is developing Grown Ups 3 with Adam Sandler, over a…

20 seconds ago

Netflix to Adapt Vault Comics’ Fantasy Series Barbaric

Netflix has another big-budget comic book adaptation in the works, with the streamer giving a…

31 seconds ago

Sen. Todd Young – US Ship Building

WASHINGTON, (WOWO) — U.S. Sen. Todd Young (R-Ind.) is part of a group of senators…

31 minutes ago

Indiana Governor Mike Braun And Cell Phone Ban In Schools

INDIANAPOLIS, Ind. (WOWO) — Indiana Governor Mike Braun signed Senate Enrolled Act 78 on Wednesday,…

31 minutes ago

Trump taps former career ICE official to lead agency

An Immigration and Customs Enforcement ICE officer's badge and weapon are seen in Washington, D.C.,…

35 minutes ago

This website uses cookies.