iso-3166-2

Lookup information about ISO-3166-2 subdivisions.

iso-3166-2.js

Lookup information about ISO-3166-2 subdivisions.

The country codes in the data are in the ISO 3166-1 alpha 2 format (US, SE ...), but there is a conversion table that makes possible to input alpha 3 codes (USA, SWE ...) to the subdivision and country functions.

https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3

> iso3166.subdivision("SE-O");
 
{ type: 'County',
  name: 'Västra Götalands län',
  countryName: 'Sweden',
  countryCode: 'SE',
  regionCode: 'O',
  code: 'SE-O' }
> iso3166.subdivision("SE", "O");
 
{ type: 'County',
  name: 'Västra Götalands län',
  countryName: 'Sweden',
  countryCode: 'SE',
  regionCode: 'O',
  code: 'SE-O' }
> iso3166.subdivision("USA", "Indiana");
 
{ type: 'state',
  name: 'Indiana',
  countryName: 'United States',
  countryCode: 'US',
  regionCode: 'IN',
  code: 'US-IN' }

Retrieves a subdivision by its full code, ex "SE-O", "US-IN".


Retrieves a subdivision by its country code and subdivision code, ex ("SWE", "O").


Retrieves a subdivision by its country code and subdivision name, ex ("US", "Indiana").


Retrieves a country by its code, ex "US", "SE", "SWE".


The raw ISO 3166-2 data, the layout is:

{
  country code (alpha 2): {
    name: country name, ex Sweden, United States ...
    sub: {
      subdivision code: {
        type: subdivision type, ex county, divison ...
        name: subdivision name, ex Västra Götaland, Indiana
      }
    }
  }
}

The ISO 3166-1 alpha 3 to alpha 2 conversion table, the layout is:

{
  country code (alpha 3): country code (alpha 2)
}

See Also

  • https://github.com/oodavid/iso-3166-2
  • https://www.npmjs.org/package/country-list
  • https://www.npmjs.org/package/i18n-iso-countries