Converts between country names, ISO 3166-1 codes and flag emojis. Has zero dependencies.
$ npm install --save country-emoji
const {flag, code, name} = require('country-emoji');
flag('CL')
// ~> ๐จ๐ฑ
code('๐จ๐ฆ')
// ~> CA
name('๐ถ๐ฆ')
// ~> Qatar
// can extract name from stringโฆ
flag('Taiwan number one!')
// ~> ๐น๐ผ
// โฆbut only if there's no ambiguity
flag('Congo and Burma')
// ~> undefined
flag('Republic of Tanzania')
// ~> ๐น๐ฟ
flag('Tanzania, United Republic of')
// ~> ๐น๐ฟ
code('Australia')
// ~> AU
code('UAE')
// ~> AE
name('AE')
// ~> United Arab Emirates
code('UK')
// ~> GB
// all values can be converted back and forth indefinitely
flag(name(flag(code(flag(name('NZ'))))))
// ~> ๐ณ๐ฟ
If you discover a bug please report it here.
Mail me at [email protected], or on twitter @meeDamian.
MIT @ Damian Mee