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 🙏

© 2026 – Pkg Stats / Ryan Hefner

world-country-utils

v0.0.1

Published

Utility functions for working with country data

Readme

world-country-utils

A lightweight, TypeScript-first utility library for fetching country-specific data like currency codes, symbols, languages, calling codes, and more using ISO codes.

Installation

npm install world-country-utils

Usage

Importing

import { countryUtils, getCountryByISO, formatAmountByISO } from 'world-country-utils';

Functions

All functions require a mandatory ISO country code (case-insensitive). If the ISO code is not found in our database, an error will be thrown.

1. Get Country Name

getCountryByISO('IN'); // "India"

2. Get Currency Code

getCurrencyByISO('US'); // "USD"

3. Get Currency Symbol

getCurrencySymbolByISO('GB'); // "£"

4. Format Amount

Formats a numeric amount with the country's currency symbol and standard grouping.

formatAmountByISO(1234.56, 'IN'); // "₹1,234.56"
formatAmountByISO(500, 'US');     // "$500.00"

5. Get Language

getLanguageByISO('FR'); // "French"

6. Get Area Code (Calling Code)

getAreaCodeByISO('AE'); // "+971"

7. Get Phone Number Placeholder

getPlaceholderByISO('US'); // "e.g. +1 1234567890"

8. Get Pincode/Postal Code Regex

getPincodeRegexByISO('IN'); // /^[1-9][0-9]{5}$/

9. Get Map Center Coordinates

getCenterByISO('IN'); // { lat: 20.593684, lng: 78.96288 }

10. Get Timezone

getTimezoneByISO('IN'); // "Asia/Kolkata"

11. Get UTC Offset

getUTCOffsetByISO('IN'); // 5.5

12. Get All ISO Codes

getAllISOCodes(); // ["AF", "AL", "DZ", ...]

11. Find ISO by Country Name

getISOByName('India'); // "IN"

12. Validate ISO

isValidISO('US'); // true
isValidISO('XX'); // false

Error Handling

If you provide an invalid or unsupported ISO code, the functions will throw an error:

try {
  getCountryByISO('INVALID');
} catch (error) {
  console.error(error.message); // "Country with ISO code "INVALID" not found"
}

API Reference

| Function | Returns | Description | | --- | --- | --- | | getCountryByISO(iso) | string | Returns the full country name. | | getCurrencyByISO(iso) | string | Returns the ISO currency code (e.g., USD). | | getLanguageByISO(iso) | string | Returns the primary language. | | getCurrencySymbolByISO(iso) | string | Returns the currency symbol (e.g., $). | | getAreaCodeByISO(iso) | string | Returns the international calling code. | | getPlaceholderByISO(iso) | string | Returns a sample phone number placeholder. | | getPincodeRegexByISO(iso) | RegExp | Returns a Regex for postal code validation. | | getPhoneRegexByISO(iso) | RegExp | Returns a Regex for phone validation (if available). | | getCenterByISO(iso) | object | Returns { lat: number, lng: number }. | | getTimezoneByISO(iso) | string | Returns the country's primary timezone. | | getUTCOffsetByISO(iso) | number | Returns the UTC offset in hours. | | formatAmountByISO(amt, iso) | string | Returns formatted currency string. | | getAllISOCodes() | string[] | Returns all supported ISO codes. | | getISOByName(name) | string \| null | Returns ISO code for a country name. | | isValidISO(iso) | boolean | Checks if an ISO code is supported. | | getAllCountries() | object | Returns the entire country dataset. |

License

ISC