demoji

1.1.0 · active · verified Thu Apr 16

demoji is a Python library (current version 1.1.0) designed to accurately find, remove, and replace emojis in text strings. It leverages data from the Unicode Consortium's emoji code repository, bundling this data at install time rather than requiring a runtime download. The library's release cadence is infrequent, with major versions introducing significant, often backwards-incompatible, changes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the `demoji` library, find all emojis and their descriptions within a string, remove emojis entirely, and replace them with their textual descriptions.

import demoji

tweet = """
#startspreadingthenews yankees win great start by 🎅🏾 going 5strong innings with 5k's🔥 🐂
solo homerun 🌋🌋 with 2 solo homeruns and👹 3run homerun… 🤡 🚣🏼 👨🏽‍⚖️ with rbi's … 🔥🔥
🇲🇽 and 🇳🇮 to close the game🔥🔥!!!….
WHAT A GAME!!..
"""

# Find all emojis and their descriptions
emojis_found = demoji.findall(tweet)
print("Emojis found:", emojis_found)

# Replace emojis with an empty string (remove them)
clean_text = demoji.replace(tweet, '')
print("Text with emojis removed:", clean_text)

# Replace emojis with their descriptions (e.g., :fire:)
desc_text = demoji.replace_with_desc(tweet)
print("Text with emoji descriptions:", desc_text)

view raw JSON →