Countries
Countries
The package includes 248+ countries with full ISO 3166-1 metadata.
Country Properties
Each country has the following fields:
| Field | Description |
|---|---|
alpha2Code | ISO 3166-1 alpha-2 code (e.g. "US") |
alpha3Code | ISO 3166-1 alpha-3 code (e.g. "USA") |
numericCode | ISO 3166-1 numeric code (e.g. 840) |
nativeName | Native country name |
capital | Capital city |
mainLanguage | Primary language code |
languages | List of spoken language codes |
tld | Top-level domain (e.g. ".us") |
callingCode | International calling code (e.g. 1) |
continent | Continent identifier |
currency | Primary currency code |
Lookup by Code
Alpha-2 Code
import { getCountryByAlpha2 } from 'infobits-intl';
const country = getCountryByAlpha2('US');
console.log(country?.nativeName); // United States
console.log(country?.capital); // Washington, D.C.Alpha-3 Code
import { getCountryByAlpha3 } from 'infobits-intl';
const country = getCountryByAlpha3('USA');
console.log(country?.alpha2Code); // USNumeric Code (Dart only)
final country = Country.fromNumericCode(840);
print(country?.nativeName); // United States
List All Countries
import { countries, CountryCode } from 'infobits-intl';
const allCountries = Object.values(countries);
console.log(allCountries.length);Filter by Continent
import { getCountriesByContinent } from 'infobits-intl';
const european = getCountriesByContinent('europe');
european.forEach(c => console.log(c.nativeName));SVG Flags
Each country has an inline SVG flag available as a string.
import { getFlag, flags } from 'infobits-intl';
// Using the lookup function
const svg = getFlag('US');
// Or access the map directly
const svgDirect = flags['US'];Emoji Flags
Country Metadata
import { getCountryByAlpha2 } from 'infobits-intl';
const country = getCountryByAlpha2('JP');
console.log(country?.callingCode); // 81
console.log(country?.tld); // .jp
console.log(country?.currency); // JPY
console.log(country?.continent); // asia
console.log(country?.mainLanguage); // ja