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 🙏

© 2026 – Pkg Stats / Ryan Hefner

country-code-kit

v1.0.5

Published

Zero-dependency list of all 249 ISO 3166-1 countries with code, name, and flag emoji. Lookup and search helpers included. Tree-shakeable, works in Node and browsers.

Readme

country-kit

Zero-dependency TypeScript package with all 249 ISO 3166-1 countries — alpha-2 code, English name, flag emoji, and ITU dial code — plus fast lookup and search helpers. Ships dual ESM + CJS builds with full type declarations. Works in Node and browsers, tree-shakeable, ~10 KB.

Install

npm i country-code-kit

Usage

import {
  countries,
  getCountryByCode,
  getCountryByName,
  getCountryByFlag,
  getFlag,
  getName,
  getDialCode,
  getCountriesByDialCode,
  isValidCode,
  searchCountries,
  codeToFlag,
  flagToCode,
} from "country-kit";

countries.length;                    // 249
getCountryByCode("in");              // { code: "IN", name: "India", flag: "🇮🇳", dialCode: "+91" }
getCountryByName("Japan");           // { code: "JP", name: "Japan", flag: "🇯🇵", dialCode: "+81" }
getCountryByFlag("🇩🇪");             // { code: "DE", name: "Germany", flag: "🇩🇪", dialCode: "+49" }

getFlag("BD");                       // "🇧🇩"
getName("FR");                       // "France"
getDialCode("BD");                   // "+880"
getDialCode("AQ");                   // null  (territory with no assigned dial code)
isValidCode("zz");                   // false

getCountriesByDialCode("+1");
// [{ code: "US", ... }, { code: "CA", ... }, ...]  — all territories sharing +1

searchCountries("uni");
// [United Arab Emirates, United Kingdom, United States, ...]
// ranked: exact match → prefix match → substring match

codeToFlag("NP");                    // "🇳🇵" (no lookup table needed)
flagToCode("🇳🇵");                   // "NP"

CommonJS works too:

const { getName } = require("country-kit");

API

| Function | Returns | | ---------------------------------- | ---------------------------------------------------------------------- | | countries | readonly Country[] — all 249 entries | | getCountryByCode(code) | Country | undefined (case-insensitive) | | getCountryByName(name) | Country | undefined (case-insensitive) | | getCountryByFlag(flag) | Country | undefined | | getFlag(code) / getName(code) | string | undefined | | getDialCode(code) | string | null | undefinednull for territories with no dial code | | getCountriesByDialCode(dialCode) | Country[] — all countries sharing a dial code (e.g. "+1") | | isValidCode(code) | boolean | | searchCountries(query) | Country[] ranked by match quality | | codeToFlag(code) | string (throws on invalid input) | | flagToCode(flag) | string | undefined |

interface Country {
  code: string;          // ISO 3166-1 alpha-2, e.g. "IN"
  name: string;          // English short name, e.g. "India"
  flag: string;          // Flag emoji, e.g. "🇮🇳"
  dialCode: string | null; // ITU calling code incl. "+", e.g. "+880". Null for territories with no assigned code.
}

License

MIT