Top Related Projects
Easy to parse data and spritesheets for emoji
:love_letter: Find the emoji that echoes your mind.
Emoji for everyone. https://twemoji.twitter.com/
šŖ One component to pick them all
Find relevant emoji from text on the command-line :open_mouth: :sparkles: :raised_hands: :horse: :boom: :see_no_evil:
Quick Overview
node-emoji is a simple and lightweight library for working with emoji in Node.js. It provides an easy way to convert emoji names to their corresponding Unicode characters and vice versa, as well as search for emoji by name or keyword.
Pros
- Simple and easy to use API
- Supports a wide range of emoji, including newer additions
- Lightweight with no external dependencies
- Includes search functionality for finding emoji by name or keyword
Cons
- Limited to text-based emoji representation (no image support)
- May not always have the most up-to-date emoji database
- Lacks advanced features like categorization or metadata
Code Examples
- Converting emoji names to Unicode characters:
const emoji = require('node-emoji');
console.log(emoji.get('coffee')); // ā
console.log(emoji.get('heart')); // ā¤ļø
- Converting Unicode characters to emoji names:
const emoji = require('node-emoji');
console.log(emoji.which('š')); // pizza
console.log(emoji.which('š¶')); // dog
- Searching for emoji by keyword:
const emoji = require('node-emoji');
console.log(emoji.search('happy'));
// [ { emoji: 'š', key: 'blush' },
// { emoji: 'š', key: 'smiley' },
// { emoji: 'š', key: 'smile' },
// ... ]
- Replacing emoji names in a string with Unicode characters:
const emoji = require('node-emoji');
const text = 'I :heart: :coffee:!';
console.log(emoji.emojify(text)); // I ā¤ļø ā!
Getting Started
To use node-emoji in your project, follow these steps:
-
Install the package using npm:
npm install node-emoji
-
Import the library in your JavaScript file:
const emoji = require('node-emoji');
-
Start using the emoji functions:
console.log(emoji.get('rocket')); // š console.log(emoji.random().emoji); // Random emoji
Competitor Comparisons
Easy to parse data and spritesheets for emoji
Pros of emoji-data
- More comprehensive emoji dataset, including metadata and image assets
- Regular updates to keep up with new emoji releases
- Supports multiple image formats (PNG, SVG) and sizes
Cons of emoji-data
- Larger file size due to included image assets
- Requires more setup and configuration for basic usage
- Not specifically designed for Node.js, may need additional integration work
Code Comparison
emoji-data:
const emojiData = require('emoji-data');
const emoji = emojiData.find_by_short_name('smile');
console.log(emoji.unified);
node-emoji:
const emoji = require('node-emoji');
console.log(emoji.get('smile'));
Key Differences
node-emoji is a lightweight Node.js-specific library focused on simple emoji operations, while emoji-data is a more comprehensive dataset that can be used across various platforms and languages. node-emoji provides easy-to-use functions for basic emoji handling, whereas emoji-data offers more detailed information and assets but requires additional setup.
emoji-data is better suited for projects requiring extensive emoji data, multiple image formats, or cross-platform compatibility. node-emoji is ideal for Node.js projects needing quick and simple emoji functionality without the overhead of additional assets.
Choose emoji-data for comprehensive emoji information and assets, or node-emoji for straightforward emoji operations in Node.js environments.
:love_letter: Find the emoji that echoes your mind.
Pros of emoji
- Lightweight and focused solely on emoji functionality
- Includes a command-line interface for easy emoji lookup
- Supports custom emoji sets and allows adding new emojis
Cons of emoji
- Less comprehensive emoji data compared to node-emoji
- Fewer utility functions for working with emojis in strings
- Not actively maintained (last update was in 2019)
Code Comparison
node-emoji:
const emoji = require('node-emoji');
console.log(emoji.get('coffee'));
console.log(emoji.emojify('I :heart: :coffee:!'));
emoji:
const emoji = require('emoji');
console.log(emoji.unicode('coffee'));
console.log(emoji.replace('I :heart: :coffee:!'));
Both libraries provide similar basic functionality for working with emojis, but node-emoji offers more extensive features and utilities. The emoji library focuses on core emoji operations and includes a CLI tool, which may be preferable for simpler use cases or command-line applications.
node-emoji has more frequent updates and a larger community, making it a more robust choice for long-term projects. However, emoji's lightweight nature and custom emoji support might be advantageous for specific use cases or when minimizing dependencies is a priority.
Choose node-emoji for comprehensive emoji handling in Node.js applications, or opt for emoji if you need a simpler solution with CLI capabilities and custom emoji support.
Emoji for everyone. https://twemoji.twitter.com/
Pros of Twemoji
- Comprehensive emoji set with high-quality vector graphics
- Cross-platform consistency and wide browser support
- Actively maintained by Twitter with frequent updates
Cons of Twemoji
- Larger file size due to SVG format
- Requires additional setup for server-side rendering
- May not integrate as seamlessly with Node.js projects
Code Comparison
node-emoji:
const emoji = require('node-emoji');
console.log(emoji.get('coffee')); // āļø
console.log(emoji.random().emoji); // š²
Twemoji:
const twemoji = require('twemoji');
console.log(twemoji.parse('āļø'));
// <img class="emoji" draggable="false" alt="āļø" src="https://twemoji.maxcdn.com/v/latest/svg/2615.svg"/>
Key Differences
- node-emoji focuses on simple text-based emoji insertion
- Twemoji provides SVG-based emoji rendering for consistent appearance
- node-emoji is more lightweight and easier to integrate in Node.js projects
- Twemoji offers better visual quality and cross-platform consistency
Use Cases
- Choose node-emoji for simple text-based emoji handling in Node.js applications
- Opt for Twemoji when visual consistency and high-quality graphics are crucial, especially in web applications
Community and Maintenance
- node-emoji has a smaller but active community
- Twemoji benefits from Twitter's resources and regular updates
šŖ One component to pick them all
Pros of emoji-mart
- Offers a complete emoji picker component for React, Preact, and Vue
- Includes skin tone selection and search functionality
- Provides customization options for appearance and behavior
Cons of emoji-mart
- Larger package size due to more comprehensive features
- May be overkill for simple emoji-related tasks
- Requires more setup and configuration for basic use cases
Code Comparison
node-emoji:
const emoji = require('node-emoji');
console.log(emoji.get('coffee'));
console.log(emoji.random().emoji);
emoji-mart:
import { Picker } from 'emoji-mart';
<Picker set='apple' onSelect={this.addEmoji} />
Key Differences
node-emoji is a lightweight library focused on simple emoji operations like getting emoji by name or finding emoji in text. It's ideal for server-side or basic client-side emoji handling.
emoji-mart is a full-featured emoji picker component for front-end frameworks. It offers a rich user interface for emoji selection, including categories, search, and skin tone modifiers.
Use Case Recommendations
Choose node-emoji for:
- Basic emoji operations in Node.js applications
- Simple emoji insertion in text-based interfaces
Choose emoji-mart for:
- Building feature-rich emoji pickers in web applications
- Projects requiring advanced emoji selection and customization
Both libraries serve different purposes and can be chosen based on the specific requirements of your project.
Find relevant emoji from text on the command-line :open_mouth: :sparkles: :raised_hands: :horse: :boom: :see_no_evil:
Pros of emoj
- Command-line interface for easy emoji search and insertion
- Supports fuzzy search for finding emojis quickly
- Integrates with clipboard for convenient copying
Cons of emoj
- Limited to command-line usage, not suitable for programmatic integration
- Fewer features for emoji manipulation compared to node-emoji
Code Comparison
node-emoji:
const emoji = require('node-emoji');
console.log(emoji.get('coffee'));
console.log(emoji.random());
console.log(emoji.search('smile'));
emoj:
$ emoj pizza
š
$ emoj "front facing baby chick"
š„
Key Differences
node-emoji is a JavaScript library for working with emojis programmatically, offering functions for getting, searching, and manipulating emojis within Node.js applications. It provides a wide range of emoji-related operations and can be integrated into various projects.
emoj, on the other hand, is a command-line tool focused on searching and inserting emojis quickly. It's designed for interactive use in terminals and doesn't provide a programming API.
Use Cases
Choose node-emoji for:
- Integrating emoji functionality into Node.js applications
- Programmatically working with emojis (parsing, replacing, etc.)
Choose emoj for:
- Quick emoji lookup and insertion in terminal environments
- Command-line based workflows involving emojis
Both projects serve different purposes and can be valuable depending on the specific requirements of your project or workflow.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
node-emoji
Friendly emoji lookups and parsing utilities for Node.js. Ć°ĀĀĀ
node-emoji
provides a fun, straightforward interface on top of the following excellent libraries:
emojilib
: provides a list of emojis and keyword search on top of itskin-tone
: parses out base emojis from skin tones
Install
npm install node-emoji
2.0 Release Ć°ĀĀĀ
This is the new 2.0 release of node-emoji, supporting ESM, new emoji and a new API.
If you want to use the old version, please check out the legacy branch.
Usage
import * as emoji from 'node-emoji'
emoji.emojify('I :heart: :coffee:!') // 'I Ć¢ĀĀ¤ĆÆĀøĀ Ć¢ĀĀĆÆĀøĀ!'
emoji.find('heart') // { emoji: 'Ć¢ĀĀ¤', name: 'heart' }
emoji.find('Ć¢ĀĀ¤ĆÆĀøĀ') // { emoji: 'Ć¢ĀĀ¤', name: 'heart' }
emoji.get('unicorn') // Ć°ĀĀ¦Ā
emoji.get(':unicorn:') // Ć°ĀĀ¦Ā
emoji.has(':pizza:') // true
emoji.has('Ć°ĀĀĀ') // true
emoji.has('unknown') // false
emoji.random() // { name: 'house', emoji: 'Ć°ĀĀĀ ' }
emoji.replace('I Ć¢ĀĀ¤ĆÆĀøĀ coffee!', 'love', { preserveSpaces: true }) // 'I love coffee!'
emoji.search(':uni:') // [ { emoji: 'Ć°ĀĀ¦Ā', name: 'unicorn' }, ... ]
emoji.strip('I Ć¢ĀĀ¤ĆÆĀøĀ coffee!') // 'I coffee!'
emoji.unemojify('Ć°ĀĀĀ for Ć°ĀĀĀ') // ':pizza: for :dancer:'
emoji.which('Ć°ĀĀ¦Ā') // 'unicorn'
API
emoji.emojify(input, options?)
Parse all markdown-encoded emojis in a string.
Parameters:
input
(string
): The input string containing the markdown-encoding emojis.options
(optional):fallback
(string
; default:""
): The string to fallback to if an emoji was not found.format
(() => (emoji: string, part: string, string: string) => string
; default:value => value
): Add a middleware layer to modify each matched emoji after parsing.
import * as emoji from 'node-emoji'
console.log(emoji.emojify('The :unicorn: is a fictitious animal.'))
// 'The Ć°ĀĀ¦Ā is a fictitious animal.'
emoji.find(emoji)
Get the name and character of an emoji.
Parameters:
emoji
(string
): The emoji to get the data of.
import * as emoji from 'node-emoji'
console.log(emoji.find('Ć°ĀĀ¦Ā'))
// { name: 'unicorn', emoji: 'Ć°ĀĀ¦Ā' }
emoji.get(name)
Get an emoji from an emoji name.
Parameters:
name
(string
): The name of the emoji to get.
import * as emoji from 'node-emoji'
console.log(emoji.get('unicorn'))
// 'Ć°ĀĀ¦Ā'
emoji.has(emoji)
Check if this library supports a specific emoji.
Parameters:
emoji
(string
): The emoji to check.
import * as emoji from 'node-emoji'
console.log(emoji.has('Ć°ĀĀ¦Ā'))
// true
emoji.random()
Get a random emoji.
import * as emoji from 'node-emoji'
console.log(emoji.random())
// { name: 'unicorn', emoji: 'Ć°ĀĀ¦Ā' }
emoji.replace(input, replacement)
Replace the emojis in a string.
Parameters:
input
(string
): The input string.replacement
(string | (emoji: string, index: number, string: string) => string
): The character to replace the emoji with. Can be either a string or a callback that returns a string.
import * as emoji from 'node-emoji'
console.log(emoji.replace('The Ć°ĀĀ¦Ā is a fictitious animal.', 'unicorn'))
// 'The unicorn is a fictitious animal.'
emoji.search(keyword)
Search for emojis containing the provided name in their name.
Parameters:
keyword
(string
): The keyword to search for.
import * as emoji from 'node-emoji'
console.log(emoji.search('honey'))
// [ { name: 'honeybee', emoji: 'Ć°ĀĀĀ' }, { name: 'honey_pot', emoji: 'Ć°ĀĀĀÆ' } ]
emoji.strip(input, options?)
Remove all of the emojis from a string.
Parameters:
-
input
(string
): The input string to strip the emojis from. -
options
(optional):preserveSpaces
(boolean
): Whether to keep the extra space after a stripped emoji.
import * as emoji from 'node-emoji'
console.log(emoji.strip('Ć°ĀĀ¦Ā The unicorn is a fictitious animal.'))
// 'The unicorn is a fictitious animal.'
console.log(
emoji.strip('Ć°ĀĀ¦Ā The unicorn is a fictitious animal.', {
preserveSpaces: true,
}),
)
// ' The unicorn is a fictitious animal.'
emoji.unemojify(input)
Convert all emojis in a string to their markdown-encoded counterparts.
Parameters:
input
(string
): The input string containing the emojis.
import * as emoji from 'node-emoji'
console.log(emoji.unemojify('The Ć°ĀĀ¦Ā is a fictitious animal.'))
// 'The :unicorn: is a fictitious animal.'
emoji.which(emoji, options?)
Get an emoji name from an emoji.
Parameters:
emoji
(string
): The emoji to get the name of.options
(optional):markdown
(boolean
; default:false
): Whether to return a":emoji:"
string instead of"emoji"
import * as emoji from 'node-emoji'
console.log(emoji.which('Ć°ĀĀ¦Ā'))
// 'unicorn'
Development
License
Special Thanks
...to Anand Chowdhary (@AnandChowdhary) and his company Pabio for sponsoring this project via GitHub Sponsors!
Contributors
Top Related Projects
Easy to parse data and spritesheets for emoji
:love_letter: Find the emoji that echoes your mind.
Emoji for everyone. https://twemoji.twitter.com/
šŖ One component to pick them all
Find relevant emoji from text on the command-line :open_mouth: :sparkles: :raised_hands: :horse: :boom: :see_no_evil:
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot