Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
countries-list
Advanced tools
Continents & countries: ISO 3166-1 alpha-2 code, name, ISO 639-1 languages, capital, currency, native name, phone. JSON, CSV and SQL.
The countries-list npm package provides a comprehensive list of countries, their codes, and other related information. It is useful for applications that need to display or process country-related data.
Get list of all countries
This feature allows you to retrieve a list of all countries along with their details such as name, native name, phone code, continent, capital, currency, and languages.
const { countries } = require('countries-list');
console.log(countries);
Get list of all continents
This feature allows you to retrieve a list of all continents and their corresponding codes.
const { continents } = require('countries-list');
console.log(continents);
Get list of all languages
This feature allows you to retrieve a list of all languages and their corresponding codes.
const { languages } = require('countries-list');
console.log(languages);
Get list of all currencies
This feature allows you to retrieve a list of all currencies and their corresponding codes.
const { currencies } = require('countries-list');
console.log(currencies);
The country-list package provides a list of countries and their ISO 3166-1 alpha-2 codes. It is simpler compared to countries-list and focuses mainly on country names and codes.
The i18n-iso-countries package provides ISO 3166-1 country codes with translations for country names in multiple languages. It is more focused on internationalization and localization compared to countries-list.
The world-countries package provides detailed information about countries, including names, codes, and geographical data. It is similar to countries-list but includes more detailed geographical information.
Continents & countries: ISO 3166-1 alpha-2 code (with alpha-2 to alpha-3 set), name, ISO 639-1 languages, capital and ISO 4217 currency codes, native name, calling codes. Lists are available in JSON, CSV and SQL formats. Also, contains separate JSON files with additional country Emoji flags data.
Version 3 comes with some data structure changes. It was completely reworked under the hood with TypeScript, ESM exports and Turborepo file structure.
Everything is strongly typed so you can easily use data with auto-complete in your IDE.
Note: If your projects depend on the old structure, carefully specify required versions in your dependencies.
Package is available via:
npm install countries-list
composer require annexare/countries-list
Module exports continents
, countries
, languages
and utility functions.
// Interfaces and types
import type {
ICountry,
ICountryData,
ILanguage,
TContinentCode,
TCountryCode,
TLanguageCode,
} from 'countries-list'
// Main data and utils
import { continents, countries, languages } from 'countries-list'
// Utils
import { getCountryCode, getCountryData, getCountryDataList, getEmojiFlag } from 'countries-list'
// Minimal data in JSON
import countries2to3 from 'countries-list/minimal/countries.2to3.min.json'
import countries3to2 from 'countries-list/minimal/countries.3to2.min.json'
import languageNames from 'countries-list/minimal/languages.native.min'
getCountryCode('Ukraine') // 'UA'
getCountryCode('Україна') // 'UA'
getCountryData('UA') // ICountryData
Built files are in the dist
directory of this repository, and packages/countries
directory contains source data.
Note: JS build contains ES modules, CommonJS and IIFE (for now)
cjs/index.js
mjs/index.js
index.iife.js
const continents = {
AF: 'Africa',
AN: 'Antarctica',
AS: 'Asia',
EU: 'Europe',
NA: 'North America',
OC: 'Oceania',
SA: 'South America',
}
const countries = {
// ...
UA: {
name: 'Ukraine',
native: 'Україна',
phone: [380],
continent: 'EU',
capital: 'Kyiv',
currency: ['UAH'],
languages: ['uk'],
},
// ...
}
const languages = {
// ...
uk: {
name: 'Ukrainian',
native: 'Українська',
},
ur: {
name: 'Urdu',
native: 'اردو',
rtl: 1,
},
// ...
}
Everything is generated from strongly typed files in packages/countries/src
, including SQL file.
Everything in dist
is generated,
so please make data related changes ONLY to files from packages/countries
, commit them.
Use npm run build
(or turbo build
, turbo test
) command to build/test generated files.
Prepared by Annexare Studio from different public sources. Feel free to use it as you need in your apps or send updates into this public repository. It's under MIT license.
FAQs
Continents & countries: ISO 3166-1 alpha-2 code, name, ISO 639-1 languages, capital, currency, native name, phone. JSON, CSV and SQL.
The npm package countries-list receives a total of 168,052 weekly downloads. As such, countries-list popularity was classified as popular.
We found that countries-list demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.