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

@countrystatecity/geojson

v1.0.2

Published

Countries, states, and cities as GeoJSON Point FeatureCollections, loaded via jsDelivr CDN

Readme

@countrystatecity/geojson

npm CI

Countries, states, and cities as GeoJSON Point FeatureCollections, loaded via jsDelivr CDN with in-memory LRU caching — same architecture as @countrystatecity/countries-browser.

Environment: 🌐 Browser / Any (no Node.js dependencies)

⚠️ Point geometry only — not boundary polygons

Every feature in this package is a single Point (one coordinate per country/state/city) — the same latitude/longitude already available via @countrystatecity/countries. There are no country/state boundary shapes (polygons) available — this package cannot power choropleth maps or shape-outline rendering. It exists to save you the one-line transform from {lat, lng} to a GeoJSON Feature, and to give you CDN-hosted, lazy-loaded FeatureCollections pre-split by country/state for direct use with L.geoJSON() (Leaflet) or as a Mapbox GL source.

If you need real boundary polygons, this package is not it — no such data is currently published upstream.

✨ Features

  • 📍 250 countries, 5,000+ states, 150,000+ cities as GeoJSON Point features
  • 🔄 Lazy loading: per-country state files, per-state city files
  • 🌐 CDN-hosted via jsDelivr with LRU in-memory caching
  • 📝 TypeScript types for Feature/FeatureCollection/properties per level

📦 Installation

npm install @countrystatecity/geojson

🚀 Quick Start

import { getCountriesGeoJSON, getStatesGeoJSON, getCitiesGeoJSON } from '@countrystatecity/geojson';

const countries = await getCountriesGeoJSON();
// { type: 'FeatureCollection', features: [{ type: 'Feature', geometry: { type: 'Point', coordinates: [-97, 38] }, properties: { id: 233, name: 'United States', iso2: 'US', iso3: 'USA' } }, ...] }

// Drop straight into Leaflet:
// L.geoJSON(countries).addTo(map);

const states = await getStatesGeoJSON('US');
const cities = await getCitiesGeoJSON('US', 'CA');

📖 API Reference

getCountriesGeoJSON()

All countries as a FeatureCollection of Point features.

  • Returns: Promise<ICountriesFeatureCollection>

getCountryGeoJSON(countryCode)

A single country as one Point feature.

  • Returns: Promise<ICountryFeature | null>

getStatesGeoJSON(countryCode)

All states/provinces of a country as a FeatureCollection.

  • Returns: Promise<IStatesFeatureCollection>

getCitiesGeoJSON(countryCode, stateCode)

All cities of a state as a FeatureCollection.

  • Returns: Promise<ICitiesFeatureCollection>

getAllCitiesGeoJSONOfCountry(countryCode)

All cities in an entire country, merged into one FeatureCollection.

  • Warning: loads every state's city file for that country.
  • Returns: Promise<ICitiesFeatureCollection>

Configuration

import { configure, resetConfiguration } from '@countrystatecity/geojson';

configure({
  baseURL: 'https://your-cdn.example.com/geojson',
  timeout: 8000,
  cacheSize: 100,
});

🔧 TypeScript Types

import type {
  IGeoJSONFeature,
  IGeoJSONFeatureCollection,
  ICountryProperties,
  IStateProperties,
  ICityProperties,
} from '@countrystatecity/geojson';

📊 Data Source

Generated from the same underlying data as @countrystatecity/countries, which sources from countries-states-cities-database. Report data issues (wrong coordinates, missing entries) there.

📄 License

ODbL-1.0