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

country-code-data

v1.1.15

Published

A lightweight npm package with complete country data, including country names, ISO codes, phone codes, capitals, currencies, official languages, and flags. Perfect for country dropdowns, phone input selectors, forms, APIs, and international applications.

Readme

🌍 Country Code Data - Complete Country List & ISO Codes NPM Package

npm version npm downloads license

📖 View Interactive Demo & Documentation

country-code-data is a lightweight npm package offering complete country information, including names, ISO codes, phone codes, capitals, currencies, languages, and flag images. Perfect for country selectors, phone inputs, forms, and global apps.


🚀 Features of Country Code Data

  • 200+ countries included
  • ISO 3166 country codes
  • International calling / phone codes
  • Country flags via reliable flagcdn.com
  • Capital city name for each country
  • Currency codes, names, and symbols included
  • Official languages for each country
  • Simple JSON structure — no dependencies
  • Works in JavaScript, TypeScript, React, Node.js, Next.js, and Vue

📦 Install Country Code Data

Install the package using npm or Yarn:

npm install country-code-data
yarn add country-code-data

🧩 How to Use Country Code Data

const countryData = require('country-code-data');

// Get all countries
const allCountries = countryData.getAllCountries();
console.log(allCountries);

// Get country by ID
const countryById = countryData.getCountryById(1);
console.log(countryById); // Afghanistan

// Get country by name
const countryByName = countryData.getCountryByName('Brazil');
console.log(countryByName);

// Get country by short name
const countryByShortName = countryData.getCountryByShortName('US');
console.log(countryByShortName);

// Get country by code
const countryByCode = countryData.getCountryByCode('+44');
console.log(countryByCode); // United Kingdom

1️⃣ Create a Country Dropdown (React/Next.js)

import countryData from "country-code-data";

export default function CountrySelect() {
const countries = countryData.getAllCountries(); 

  return (
    <select>
      {countryData.map(country => (
        <option key={country.shortName} value={country.shortName}>
          {country.name} ({country.code})
        </option>
      ))}
    </select>
  );
}

📊 Data Structure

Each country entry looks like this:

  {
    "id": 14,
    "name": "Bangladesh",
    "shortName": "BD",
    "code": "+880",
    "flag": "https://flagcdn.com/w40/bd.png",
    "capital": "Dhaka",
    "currency": {
      "code": "BDT",
      "name": "Bangladeshi Taka",
      "symbol": "৳"
    },
    "languages": ["Bengali"]
  }

| Field | Description | | ------------ | ------------------------------------------------------------------ | | id | Auto-incremented unique ID | | name | Full country name | | shortName | ISO 3166-1 alpha-2 code | | code | International phone calling code | | flag | URL of the country’s flag image | | capital | Capital of the country’s | | currency | Object containing the country’s currency details: | |     code | ISO 4217 currency code (e.g., "BDT") | |     name | Full currency name (e.g., "Bangladeshi Taka") | |     symbol | Currency symbol (e.g., "৳") | | languages | Array of official or widely spoken languages (e.g., ["Bengali"]) |


🌐 Use Cases for Country Data

  • 🌎 Country dropdowns for web or mobile apps
  • 📞 Phone input selectors with country flags
  • 💡 APIs and data services that require global country info
  • 🧠 Educational or data visualization projects
  • ⚙️ Internationalization (i18n) in apps

⚡ Performance & Size

  • File size: ~48 KB (minified)
  • Dependencies: None
  • Format: Plain JSON
  • Compatible with: ESM & CommonJS

License

MIT