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

react-iso-3166

v0.1.4

Published

Tiny ISO 3166-1 alpha-2 ↔ alpha-3 converter with smart aliases

Readme

React ISO 3166

Tiny ISO 3166-1 alpha-2 ↔ alpha-3 ↔ numeric ↔ dial code converter with smart aliases, powered by the official ISO CSV.

Features

Install

npm install react-iso-3166

Usage

Importing

ESM (modern Node.js, Vite, etc):

import { toISO3, toISO2, mustISO3, mustISO2, ISO2_TO_3, ISO2_TO_N3, N3_TO_2, ISO2_TO_DIAL, DIAL_TO_2 } from 'react-iso-3166';

CommonJS (require):

const { toISO3, toISO2, mustISO3, mustISO2, ISO2_TO_3, ISO2_TO_N3, N3_TO_2, ISO2_TO_DIAL, DIAL_TO_2 } = require('react-iso-3166');

API

  • toISO3(code) — Convert ISO alpha-2 or alias to alpha-3. Returns undefined if not found.
  • toISO2(code) — Convert ISO alpha-3 to alpha-2. Returns undefined if not found.
  • mustISO3(code) — Like toISO3, but throws if not found.
  • mustISO2(code) — Like toISO2, but throws if not found.
  • ISO2_TO_3 — Object map: alpha-2 → alpha-3 (e.g., ISO2_TO_3['FR'] // 'FRA').
  • ISO2_TO_N3 — Object map: alpha-2 → numeric code (string, e.g., ISO2_TO_N3['FR'] // '250').
  • N3_TO_2 — Object map: numeric code (string) → alpha-2 (e.g., N3_TO_2['250'] // 'FR').
  • ISO2_TO_DIAL — Object map: alpha-2 → dial code string (as in CSV, may include hyphens for NANP overlays, e.g., ISO2_TO_DIAL['BS'] // '1-242').
  • DIAL_TO_2 — Object map: dial code string → alpha-2 (e.g., DIAL_TO_2['44'] // 'GB').

Examples

import { toISO3, toISO2, mustISO3, mustISO2, ISO2_TO_3, ISO2_TO_N3, N3_TO_2, ISO2_TO_DIAL, DIAL_TO_2 } from 'react-iso-3166';

import { toISO3, toISO2, ISO2_TO_3, ISO2_TO_N3, N3_TO_2 } from 'react-iso-3166';

toISO3('pt'); // 'PRT'
toISO2('FRA'); // 'FR'
ISO2_TO_3['DE'];     // 'DEU'
ISO2_TO_N3['DE'];    // '276'
N3_TO_2['276'];      // 'DE'
ISO2_TO_DIAL['GB'];  // '44'
DIAL_TO_2['1-242'];  // 'BS'

Aliases

Some common aliases are supported:

  • 'UK''GBR' (United Kingdom)
  • 'EL''GRC' (Greece, EU context)
  • 'XK''XKX' (Kosovo, user-assigned)

Updating the Mappings

If you want to update the mappings from the official ISO CSV:

node scripts/generate-from-csv.mjs

CLI Generation

If you want to update the mappings:

node scripts/generate-from-csv.mjs

License

MIT