npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

language-emoji

v2.1.1

Published

Emoji for a language code. Includes name in English and native language.

Readme

Language Emoji 🌍

language-emoji is a lightweight and easy-to-use package that helps you transform language codes (e.g., en_US or en) into country emoji flags 🌎, language names, and native language names.

Features ✨

  • 🌍 Supports multiple languages with language codes.
  • 🇺🇸 Converts language codes to emoji flags.
  • 📝 Provides English and native names for languages.
  • Lightweight and fast — ideal for web and server-side projects, no dependencies.
  • 🤖 Useful for Telegram bots: parse users language_code easily.

Installation 📦

Using npm

npm install language-emoji

Using yarn

yarn add language-emoji

Usage 🚀

Import the package

import { langFlag, fallbackLangFlag, langName, langNativeName } from 'language-emoji';

Example 1: Get Emoji Flag

import { langFlag, fallbackLangFlag } from 'language-emoji';

console.log(langFlag('en_US'));   // Output: 🇺🇸
console.log(langFlag('ru'));      // Output: 🇷🇺

console.log(langFlag('lalala'));           // Output: undefined
console.log(fallbackLangFlag('lalala'));   // Output: 🌎

Example 2: Get Language Name

import { langName } from 'language-emoji';

console.log(langName('es'));   // Output: Spanish
console.log(langName('de'));   // Output: German

Example 3: Get Native Language Name

import { langNativeName } from 'language-emoji';

console.log(langNativeName('zh'));   // Output: 中文
console.log(langNativeName('ja'));   // Output: 日本語

API Reference 📚

langData(lang: string): LanguageData | undefined

Returns the language data for a given language code.

  • lang: Language code in formats like en_US or fr.
  • Returns: An object containing:
    • flag: Emoji flag string (e.g., 🇺🇸).
    • name: English name string (e.g., English).
    • native_name: Native name string (e.g., Français).

langFlag(lang: string): string | undefined

Returns the emoji flag for a given language code.

  • lang: Language code in formats like en_US or fr.
  • Returns: Emoji flag string (e.g., 🇺🇸) or undefined if not found.

fallbackLangFlag(lang: string): string

Returns the emoji flag for a given language code, falling back to 🌍 if not found.

  • lang: Language code.
  • Returns: Emoji flag string (e.g., "🇺🇸") or "🌍" if not found.

langName(lang: string): string

Returns the English name of the language for a given code.

  • lang: Language code.
  • Returns: English name string (e.g., "Spanish") or lang code itself if not found.

langNativeName(lang: string): string

Returns the native name of the language for a given code.

  • lang: Language code.
  • Returns: Native name string (e.g., "Français") or lang code itself if not found.

Supported Languages 🌐

The package supports a wide range of languages. Some examples include:

  • en - English 🇺🇸
  • fr - French 🇫🇷
  • es - Spanish 🇪🇸
  • de - German 🇩🇪
  • zh - Chinese 🇨🇳
  • And more...

For the full list of supported languages, check the data object in the source code.

This package supports the following language code formats:

  • IETF BCP 47 - e.g., en-US, fr-CA
  • ISO 639-1 - e.g., en, fr
  • Underscore Format - e.g., en_US, fr_CA (commonly used in localization systems)

You can input any of these formats, and the package will normalize them for consistent handling.


Contributing 🤝

Contributions are welcome! Feel free to open an issue or submit a pull request on GitHub.


License 📄

This project is licensed under the MIT License.


Contact 📬

For questions or support, reach out via:


Enjoy using language-emoji! 🌍✨