Friendly emoji lookups and parsing utilities for Node.js. π
A comprehensive emoji library for Node.js that provides utilities for parsing, searching, and working with emojis. Features both a JavaScript API and a command-line interface.
npm install -g @involvex/emoji-cliyarn global add @involvex/emoji-clipnpm add -g @involvex/emoji-clibun add -g @involvex/emoji-cliYou can also use the CLI without installing it globally:
npx @involvex/emoji-cli --search "heart"
npx @involvex/emoji-cli --get "heart"
npx @involvex/emoji-cli --randombunx @involvex/emoji-cli --search "heart"
bunx @involvex/emoji-cli --get "heart"
bunx @involvex/emoji-cli --randomRequirements: Node.js >= 18
import { emojify, search, random, get } from '@involvex/emoji-cli'
// Convert text with emoji codes to actual emojis
const text = emojify('I :heart: JavaScript! :tada:')
console.log(text)
// Output: "I β€οΈ JavaScript! π"
// Search for emojis by name
const heartEmojis = search('heart')
console.log(heartEmojis)
// Output: [{ emoji: 'β€οΈ', name: 'heart' }, { emoji: 'π', name: 'broken_heart' }, ...]
// Get a specific emoji
const heart = get('heart')
console.log(heart)
// Output: 'β€οΈ'
// Get a random emoji
const randomEmoji = random()
console.log(randomEmoji)
// Output: { emoji: 'π', name: 'rainbow' }After installation, you can use the emoji-cli command:
# Search for emojis
emoji-cli --search "heart"
# Get a specific emoji
emoji-cli --get "heart"
# Convert text to emojis
emoji-cli --emojify "I love JavaScript!"
# Convert emojis back to text
emoji-cli --unemojify "I β€οΈ JavaScript!"
# Get a random emoji
emoji-cli --random
# Check if an emoji exists
emoji-cli --has "heart"- π Powerful Search: Search emojis by name, keyword, or pattern matching
- π Text Conversion: Convert between text with emoji codes and actual emojis
- π² Random Selection: Get random emojis for variety and fun
- π§ Utility Functions: Comprehensive set of emoji manipulation utilities
- π₯οΈ CLI Interface: Command-line tool for emoji operations
- π¦ Tree Shaking: Modern ESM module support for better bundling
- π§ͺ Well Tested: Comprehensive test coverage with Vitest
- β‘ TypeScript: Full TypeScript support with proper type definitions
Parse markdown-encoded emojis in a string and convert them to actual emoji characters.
Parameters:
input(string): The text containing emoji codes like:heart:options(object, optional):fallback(string | function): Fallback for unknown emoji codesformat(function): Custom formatting function for matched emojis
Returns: string
Examples:
import { emojify } from '@involvex/emoji-cli'
emojify('Hello :world:!')
// Output: "Hello π!"
// With custom fallback
emojify('I :unknown: this', { fallback: 'β' })
// Output: "I β this"
// With custom format function
emojify('I :heart: this', {
format: (emoji, code) => `${emoji} (${code})`,
})
// Output: "I β€οΈ (:heart:) this"Search for emojis by name or pattern.
Parameters:
keyword(string | RegExp): Search term or regular expression
Returns: Array of { emoji, name } objects
Examples:
import { search } from '@involvex/emoji-cli'
search('heart')
// Output: [{ emoji: 'β€οΈ', name: 'heart' }, { emoji: 'π', name: 'broken_heart' }]
search(/^heart/)
// Output: All emojis starting with "heart"
search('face')
// Output: All emojis containing "face" in their nameGet an emoji by its code or name.
Parameters:
codeOrName(string): Emoji code (e.g., 'heart') or emoji character
Returns: string | undefined
Examples:
import { get } from '@involvex/emoji-cli'
get('heart')
// Output: 'β€οΈ'
get('β€οΈ')
// Output: 'β€οΈ'
get('non-existent')
// Output: undefinedGet a random emoji.
Returns: { emoji, name } object
Examples:
import { random } from '@involvex/emoji-cli'
random()
// Output: { emoji: 'π', name: 'rainbow' }Replace emojis in a string with custom replacements.
Parameters:
input(string): Input text containing emojisreplacement(string | function): Replacement text or functionoptions(object, optional):preserveSpaces(boolean): Whether to preserve spaces after emojis
Returns: string
Examples:
import { replace } from '@involvex/emoji-cli'
replace('I β€οΈ JavaScript!', '[EMOJI]')
// Output: "I [EMOJI] JavaScript!"
replace('I β€οΈ JavaScript!', (emoji, index) => `[${emoji.name}]`)
// Output: "I [heart] JavaScript!"Remove all emojis from a string.
Parameters:
input(string): Input text
Returns: string
Examples:
import { strip } from '@involvex/emoji-cli'
strip('I β€οΈ JavaScript! π')
// Output: "I JavaScript!"Convert emojis back to their markdown codes.
Parameters:
input(string): Input text containing emojis
Returns: string
Examples:
import { unemojify } from '@involvex/emoji-cli'
unemojify('I β€οΈ JavaScript!')
// Output: "I :heart: JavaScript!"Get the name/code of an emoji.
Parameters:
emoji(string): The emoji characteroptions(object, optional):markdown(boolean): Return in markdown format
Returns: string | undefined
Examples:
import { which } from '@involvex/emoji-cli'
which('β€οΈ')
// Output: 'heart'
which('β€οΈ', { markdown: true })
// Output: ':heart:'Find an emoji by code or name, returning both emoji and name.
Parameters:
codeOrName(string): Emoji code or name
Returns: { emoji, name } | undefined
Examples:
import { find } from '@involvex/emoji-cli'
find('heart')
// Output: { emoji: 'β€οΈ', name: 'heart' }
find('β€οΈ')
// Output: { emoji: 'β€οΈ', name: 'heart' }Check if an emoji exists.
Parameters:
codeOrName(string): Emoji code or name
Returns: boolean
Examples:
import { has } from '@involvex/emoji-cli'
has('heart')
// Output: true
has('non-existent')
// Output: false- Node.js: >= 18.0.0
- Package Manager: npm, yarn, pnpm, or bun
The package includes full TypeScript definitions. No additional types package needed:
import { emojify, search, type EmojifyOptions } from '@involvex/emoji-cli'
const options: EmojifyOptions = {
fallback: 'β',
format: (emoji, name) => `${emoji} (${name})`,
}
const result = emojify('Hello :world:!', options)"Cannot find module '@involvex/emoji-cli'"
- Ensure you have Node.js >= 18 installed
- Try reinstalling:
npm install @involvex/emoji-cli - Check that your package manager is up to date
"Unknown command" in CLI
- For global CLI usage: Ensure you've installed the package globally with your package manager
- Try without installation:
npx @involvex/emoji-cli --helporbunx @involvex/emoji-cli --help - For npm global install:
npm install -g @involvex/emoji-cli - For yarn global install:
yarn global add @involvex/emoji-cli - For pnpm global install:
pnpm add -g @involvex/emoji-cli - For bun global install:
bun add -g @involvex/emoji-cli - Check that the emoji name/code exists using
search()
"Emoji not found"
- Verify the emoji name using
search()function - Some emojis may not be available in all fonts/platforms
- Check for typos in emoji names
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π Documentation: This README and inline code documentation
We welcome contributions! Please see our Contributing Guide for details.
-
Clone the repository
git clone https://github.com/involvex/node-emoji.git cd node-emoji -
Install dependencies
npm install
-
Run tests
npm test -
Build the project
npm run build
-
Run linting
npm run lint
- Follow the existing code style and conventions
- Add tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting PRs
- Use conventional commit messages
Emojis are sourced from the emojilib package. To request new emojis, please contribute to that project.
This project is licensed under the MIT License - see the LICENSE.md file for details.
- Emoji Data: emojilib - Comprehensive emoji database
- Inspiration: Built upon the original node-emoji by Daniel Biedermann
- Community: Thanks to all contributors and users who make this project better
emoji, simple, emoticons, emoticon, emojis, smiley, smileys, smilies, ideogram, ideograms
- Node.js: >= 18
- @sindresorhus/is: Type checking and validation utilities
- char-regex: Character matching utilities
- emojilib: Emoji database and utilities
- jiti: JavaScript Runtime detection
- skin-tone: Skin tone variation support
- TypeScript: Static type checking
- Vitest: Testing framework
- ESLint: Code linting
- Prettier: Code formatting
- tsup: Build tooling
Made with π by Involvex
β Star this project on GitHub if you find it helpful!