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

@cyber_squad_inc/world-locations

v1.1.6

Published

Offline world dataset (countries, states, cities) with flags, phone codes, and ISO codes — maintained by Cyber Squad Inc.

Readme

✨ Features

  • 249 countries with complete data
  • States/Provinces for each country
  • Cities with coordinates and population data
  • ISO codes (ISO2, ISO3, numeric)
  • Phone codes and timezones
  • Flags (rectangular and round)
  • Currencies and languages
  • Regions and subregions
  • Districts and suburbs (where available)
  • Zero dependencies for runtime usage
  • Offline-first - no API calls needed

📦 Install

npm install @cyber_squad_inc/world-locations

🚀 Usage

Basic Usage

import { getCountries, getCountry, getStates, getCities } from '@cyber_squad_inc/world-locations';

// Get all countries (lightweight list)
const countries = getCountries();
console.log(countries);
// [
//   {
//     name: "United States",
//     officialName: "United States of America",
//     iso2: "US",
//     iso3: "USA",
//     phoneCode: "1",
//     flag: "https://flagcdn.com/w320/us.png",
//     capital: "Washington, D.C.",
//     region: "Americas",
//     subregion: "North America",
//     // ... more fields
//   },
//   // ... 248 more countries
// ]

// Get full country data
const usa = getCountry('US');
console.log(usa.name.common); // "United States"
console.log(usa.states.length); // 50+ states

// Get states for a country
const states = getStates('BD');
console.log(states);
// [
//   { name: "Dhaka", code: "13", cities: [...] },
//   { name: "Chittagong", code: "10", cities: [...] },
//   // ... more states
// ]

// Get cities for a specific state
const cities = getCities('BD', 'Dhaka');
console.log(cities);
// [
//   { name: "Dhaka", latlng: [23.8103, 90.4125], population: 10356500 },
//   { name: "Gazipur", latlng: [24.0023, 90.4264], population: 1200000 },
//   // ... more cities
// ]

Advanced Usage

import { 
  searchCountries, 
  getCountriesByRegion, 
  getCountriesBySubregion 
} from '@cyber_squad_inc/world-locations';

// Search countries by name
const results = searchCountries('united');
console.log(results);
// [
//   { name: "United States", iso2: "US", ... },
//   { name: "United Kingdom", iso2: "GB", ... },
//   { name: "United Arab Emirates", iso2: "AE", ... }
// ]

// Get countries by region
const europeanCountries = getCountriesByRegion('Europe');
console.log(europeanCountries.length); // 50+ countries

// Get countries by subregion
const scandinavianCountries = getCountriesBySubregion('Northern Europe');
console.log(scandinavianCountries);
// [
//   { name: "Denmark", iso2: "DK", ... },
//   { name: "Finland", iso2: "FI", ... },
//   { name: "Iceland", iso2: "IS", ... },
//   { name: "Norway", iso2: "NO", ... },
//   { name: "Sweden", iso2: "SE", ... }
// ]

Default Import

import worldLocations from '@cyber_squad_inc/world-locations';

const countries = worldLocations.getCountries();
const usa = worldLocations.getCountry('US');
const states = worldLocations.getStates('US');
const cities = worldLocations.getCities('US', 'California');

📊 Data Structure

Country Object

interface Country {
  name: {
    common: string;
    official: string;
  };
  iso2: string;
  iso3: string;
  numericCode: string;
  region: string;
  subregion: string;
  tld: string;
  phoneCode: string;
  capital: string;
  currencies: Record<string, string>;
  timezones: Array<{
    zoneName: string;
    gmtOffset: number;
    gmtOffsetName: string;
    abbreviation: string;
    tzName: string;
  }>;
  flagRect: string;
  flagRound: string;
  states: State[];
}

State Object

interface State {
  id: number;
  name: string;
  code: string;
  shortName: string;
  cities: City[];
}

City Object

interface City {
  id: number;
  name: string;
  latlng: [number, number];
  population: number | null;
  districts: string[];
  suburbs: string[];
}

🛠️ Development

This package is built from multiple data sources:

  • REST Countries for country data, flags, and codes
  • GeoNames for city coordinates and population
  • OpenStreetMap for districts and suburbs
  • countriesnow.space for states and cities

📄 License

MIT License - see LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📞 Support

If you have any questions or need help, please open an issue on GitHub.