RepositoryJavaScriptUSUnited States
thekelvinliu

thekelvinliu/country-code-emoji

convert country codes (ISO 3166-1 alpha-2) to corresponding emoji flags (unicode regional indicator symbols)

142stars
11forks
2issues
1views

country-code-emoji

convert country codes (ISO 3166-1 alpha-2) to corresponding emoji flags (unicode regional indicator symbols)

about

this is a completely dependency-free module to convert ascii letters to regional indicator symbols; for valid country codes, this results in that country's emoji flag. commonjs and es module builds are available via package.json's main and module. it relies on String.fromCodePoint internally, but does not provide any polyfills. if your environment does not support String.fromCodePoint, grab a polyfill like this one from mdn.

install

# npm
npm install country-code-emoji

# yarn
yarn add country-code-emoji

usage

// commonjs module
const { countryCodeEmoji, emojiCountryCode } = require('country-code-emoji');
countryCodeEmoji('US'); // returns '🇺🇸'
emojiCountryCode('🇺🇸'); // returns 'US'

// es module
import { countryCodeEmoji, emojiCountryCode } from 'country-code-emoji';
['AE', 'CN', 'GB'].map(countryCodeEmoji); // returns ['🇦🇪', '🇨🇳', '🇬🇧']
['🇦🇪', '🇨🇳', '🇬🇧'].map(emojiCountryCode); // returns ['AE', 'CN', 'GB']

this module exports a pair of functions to convert country codes to/from flag emojis. the first is countryCodeEmoji(cc). it accepts a two-character (case-insensitive) country code and throws a TypeError if anything else is passed. more specifically, cc is expected to be a ISO 3166-1 alpha-2 country code. to keep things simple, if cc a two letter string, but not an actual ISO 3166-1 alpha-2 code, the regional indicator symbols corresponding to the letters in cc are returned. the second is emojiCountryCode(flag), which accepts a flag emoji and similarly throws a TypeError if anything else is passed.

// default export is countryCodeEmoji
import flag from 'country-code-emoji';

flag(); // throws TypeError
['Us', 'uS', 'us'].every(e => flag(e) === flag('US')); // returns true
flag('UK'); // returns '🇺🇰'

Similar Projects

Discover other similar projects and AI models.

RepositoryPython
cvzi/flag

Flag emoji from country codes for Python 🏳️‍🌈🌍

67
Nov 11, 2026
RepositoryPHP
raramuridesign/mysql-country-list

mysql insert country list into database

479
Nov 1, 2026
RepositoryPHP
lwwcas/laravel-countries

Laravel country database package with Eloquent models, ISO 3166 codes, country flags, GeoJSON maps, phone codes, currencies and translations in 9 languages. Built with migrations & seeders for Laravel 10–13.

132
Jul 16, 2026
RepositoryJava
blongho/worldCountryData

Android library for country flag, currency, and other country information

102
Oct 14, 2026
RepositoryRuby
sshaw/normalize_country

Convert country names and codes to a standard.

70
Feb 22, 2025
Repository
tuannvbg/unicode-flags-for-windows

Fix flag emoji for Windows 10/11: show full‑color country flags 🇻🇳 🇺🇸 🇯🇵 instead of VN/US/JP two‑letter codes. Unicode 17.0 & 18.0 + Noto Color Emoji 18.0 (2D ready, 3D coming soon). No waiting. Just fix it.

70
Nov 24, 2026
RepositoryTypeScript
necessarylion/country-list-with-dial-code-and-flag

Country Flag with Dial Number Code

63
Oct 28, 2026
RepositoryJavaScript
carloscuesta/gitmoji-cli

A gitmoji interactive cli tool for using emojis on commits. 💻

4.8k
Dec 1, 2026
RepositoryJavaScript
mathiasbynens/emoji-regex

A regular expression to match all Emoji-only symbols as per the Unicode Standard.

1.9k
Sep 15, 2026