enum-countries - Comprehensive Country Data Package

A complete, type-safe collection of country data including ISO codes, languages, telephone codes, and more.
📦 Installation
npm install enum-countries
yarn add enum-countries
pnpm add enum-countries
🌍 Features
- ✅ Complete country data for all recognized sovereign states
- 🏷 Standardized codes:
- ISO 3166 (alpha-2, alpha-3, numeric)
- FIFA country codes
- International telephone codes
- 🌐 Multilingual support:
- Official languages with native titles
- Locale codes (e.g., 'fr-FR')
- Note: Some language data still needs completion
- 🔗 Top-level domains (TLDs)
- 🛠 Developer friendly:
- Full TypeScript support
- Tree-shakable ES modules
- Zero dependencies
📚 Basic Usage
JavaScript/CommonJS
const { countries } = require('enum-countries');
console.log(countries.france.iso_3166.alpha2);
console.log(countries.japan.telephone.code);
TypeScript/ES Modules
import { countries } from 'enum-countries';
const germany = Object.values(countries).find((c) => c.iso_3166.alpha2 === 'DE');
console.log(germany?.languages);
🔍 Advanced Usage
Type-Safe Country Access
import type { CountriesMap } from 'enum-countries';
function formatPhoneNumber(countryCode: keyof CountriesMap, phoneNumber: string): string {
const country = countries[countryCode];
return `+${country.telephone.code} ${phoneNumber}`;
}
Available Utility Functions
const countryCodes = Object.keys(countries);
const fifaCodes = Object.values(countries).map((c) => c.fifa.code);
const countryByTld = Object.values(countries).find((c) => c.iso_3166.TLD === '.it');
📊 Data Structure
Each country object contains:
{
iso_3166: {
alpha3: string;
alpha2: string;
numeric: string;
capital_subdivision: string | null;
state_name: string;
sovereignty: string;
TLD: string;
};
fifa: {
code: string;
};
telephone: {
code: string;
};
languages: {
[languageName: string]: {
local: string;
title: string;
}
};
}
🤖 TypeScript Support
Fully typed with included declarations:
interface CountryData {
iso_3166: {
alpha3: string;
alpha2: string;
numeric: string;
capital_subdivision: string | null;
state_name: string;
sovereignty: string;
TLD: string;
};
fifa: { code: string };
telephone: { code: string };
languages: Record<string, { local: string; title: string }>;
}
interface CountriesMap {
[countryName: string]: CountryData;
}
🚀 Version History
| 1.0.* | Include all languages and iso standard codes |
🤝 Contributing
We welcome contributions to improve this package! Here's how you can help:
- Report Issues: Found incorrect data? Open an issue!
- Add Missing Data: Particularly language information
- Improve Typings: Enhance the TypeScript experience
- Add Features: Suggest new useful data fields
To contribute:
- Fork the repository
- Create your feature branch (
git checkout -b feature/your-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin feature/your-feature)
- Open a Pull Request
📜 License
MIT © A.M.Hamidi Pour