ランキングに戻る

annexare/Countries

TypeScriptannexare.github.io/Countries/

Countries, Languages & Continents data (capital and currency, native name, calling codes).

countriescountry-codesjsonsqliso3166csvcurrenciescontinentcapitallocalesemojitypings
スター成長
スター
1.3k
フォーク
425
週間成長
Issue
9
5001k
2014年7月2018年7月2022年7月2026年7月
成果物npmnpm install countries
README

Countries, Languages & Continents data

Monthly Downloads NPM Packagist CI: JS CI: PHP Twitter

Continents & countries: ISO 3166-1 alpha-2 code (with alpha-2 to alpha-3 set), name, ISO 639-1 languages, capital, ISO 4217 currencies (with symbols & numeric 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.0: Breaking changes

Version 3 comes with some data structure changes. It was completely reworked under the hood with TypeScript, ESM exports and a Bun workspaces monorepo 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.

Installation

Package is available via:

  • Bun bun add countries-list
  • NPM npm install countries-list
  • Composer / Packagist composer require annexare/countries-list

Usage (version 3.x)

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 cjs/index.js
  • ESM mjs/index.js
  • IIFE index.iife.js

Currencies (ISO 4217)

Full ISO 4217 currency data — English and native name, UI symbol, native symbol, 3-digit numeric code and minor-unit decimals — is an opt-in import via the countries-list/currencies subpath, so it does not affect the main bundle size:

import type { ICurrency, ICurrencyData, TCurrencyCode } from 'countries-list'
import { currencies, getCurrency, getCurrencyByNumeric } from 'countries-list/currencies'

// Minimal maps (code -> value)
import currencySymbols from 'countries-list/minimal/currencies.symbol.min.json'
import currencyNumbers from 'countries-list/minimal/currencies.numeric.min.json'

currencies.UAH // { name: 'Ukrainian Hryvnia', native: 'українська гривня', symbol: '₴', symbolNative: '₴', numeric: '980', decimals: 2 }
getCurrency('JPY') // ICurrencyData: { code: 'JPY', name: 'Japanese Yen', symbol: '¥', decimals: 0, ... }
getCurrencyByNumeric('840') // ICurrencyData for USD — numeric lookup, e.g. for banking

The dataset covers the complete active ISO 4217 list plus a few withdrawn codes still referenced by country data (e.g. ANG, flagged with withdrawn: true). symbol falls back to the ISO code where a currency has no distinct Latin glyph (e.g. CHF, KWD); the local glyph is then in symbolNative. Symbols come from Unicode CLDR (ISO 4217 itself defines no symbols).

Data structure examples

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,
  },
  // ...
}

const currencies = {
  // ...
  UAH: {
    name: 'Ukrainian Hryvnia',
    native: 'українська гривня',
    symbol: '₴',
    symbolNative: '₴',
    numeric: '980',
    decimals: 2,
  },
  // ...
}

Contributing to this repository

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 bun run build / bun run test to build/test generated files.

The currencies dataset (packages/countries/src/data/currencies.ts) is generated from the official ISO 4217 list and Unicode CLDR via packages/scripts/generateCurrencies.ts. Refresh it with cd packages/scripts && bun run generate:currencies (requires network) when ISO 4217 publishes an update, rather than editing the data by hand.

Credits

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.

関連リポジトリ
dr5hn/countries-states-cities-database

🌍 Discover our global repository of countries, states, and cities! 🏙️ Get comprehensive data in JSON, SQL, PSQL, SQLSERVER, MONGODB, SQLITE, XML, YAML, and CSV formats. Access ISO2, ISO3 codes, country code, capital, native language, timezones (for countries), and more. #countries #states #cities

PythonPyPIOpen Data Commons Open Database License v1.0citiescountries
countrystatecity.in
9.7k3k
mledoze/countries

World countries in JSON, YAML, CSV and XML. Any help is welcome!

PHPPackagistOpen Data Commons Open Database License v1.0countriesgeojson
mledoze.github.io/countries/
6.2k1.3k
lukes/ISO-3166-Countries-with-Regional-Codes

ISO 3166-1 country lists merged with their UN Geoscheme regional codes in ready-to-use JSON, XML, CSV data sets

RubyRubyGemsOtherregion-codescountries
2.5k3.3k
countries/countries

All sorts of useful information about every country packaged as convenient little country objects. It includes data from ISO 3166 (countries and states/subdivisions ), ISO 4217 (currency), and E.164 (phone numbers).

RubyRubyGemsMIT Licenserubyiso3166
2.4k684
apilayer/restcountries

Get information about countries via a RESTful API

JavaMavenMozilla Public License 2.0rest-countriesrest
restcountries.eu
2.3k359
djaiss/mapsicon

A free collection of maps for every country in the world, available in 11 sizes or in SVG.

HTMLiconscountries
2.2k194
antonioribeiro/countries

Laravel countries and currencies

PHPPackagistBSD 3-Clause "New" or "Revised" Licenselaravellaravel-countries
1.9k300
rinvex/countries

Rinvex Country is a simple and lightweight package for retrieving country details with flexibility. A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, flags, emoji, and other attributes for all 250 countries worldwide at your fingertips.

PHPPackagistMIT Licensephpcountries
rinvex.com
1.7k216
stefangabos/world_countries

Constantly updated lists of world countries and their associated alpha-2, alpha-3 and numeric country codes as defined by the ISO 3166 standard, available in CSV, JSON , PHP, SQL and XML formats, in multiple languages and with national flags included; also available are the ISO 3166-2 codes of provinces/ states associated with the countries

PHPPackagistCreative Commons Attribution Share Alike 4.0 Internationalcountriesflags
stefangabos.github.io/world_countries/
1.6k391
HatScripts/circle-flags

A collection of 400+ minimal circular SVG country, state and language flags

HTMLMIT Licensesvgcountry-flags
hatscripts.github.io/circle-flags
1.5k334
carmen-ruby/carmen

A repository of geographic regions for Ruby

RubyRubyGemsOtherrubycountries
1.2k272
samayo/country-json

A simple data of the world by country each in JSON format.

JavaScriptnpmMIT Licensejson-formatlanguage
data.world/samayo
1.1k796