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

zipcodes-plus

v1.0.0

Published

Fast, zero-dependency US ZIP code and Canadian postal code lookup - city, state/province, county, and coordinates, with TypeScript types and ESM + CommonJS builds

Downloads

192

Readme

zipcodes-plus

Fast, zero-dependency US ZIP code and Canadian postal code lookup — city, state/province, county, and coordinates. Ships ESM and CommonJS builds with TypeScript types.

Install

npm install zipcodes-plus

Usage

// ESM
import zipcodes, { find, findByCity, findByRadius } from "zipcodes-plus"

// CommonJS
const zipcodes = require("zipcodes-plus")
const { find } = require("zipcodes-plus")
find("90210")
// {
//   city: 'Beverly Hills', state: 'California', stateCode: 'CA',
//   county: 'Los Angeles', country: 'US',
//   placeName: 'Beverly Hills',
//   latitude: 34.0901, longitude: -118.4065, isValid: true
// }

find("M5V 3L9")
// {
//   city: 'Toronto', state: 'Ontario', stateCode: 'ON',
//   county: 'Toronto', country: 'CA',
//   placeName: 'Downtown Toronto (CN Tower / King and Spadina / ...)',
//   latitude: 43.6404, longitude: -79.3995, isValid: true
// }

You never pass a country. US ZIPs are five digits and Canadian codes start with a letter, so the format identifies the country. Canadian input is accepted in any shape — "M5V", "M5V 3L9", "m5v3l9" all resolve to the same record.

Canadian codes

Canadian results are at FSA granularity — the first three characters (M5V), a neighbourhood or small town. Passing a full six-character code works and returns its FSA record. Full six-character data is licensed by Canada Post and is not included.

city is the municipality. placeName is the raw GeoNames label, which for Canada describes the FSA's delivery area.

find("M5V 3L9").city        // 'Toronto'
find("M5V 3L9").placeName   // 'Downtown Toronto (CN Tower / ...)'

API

| Function | Returns | |---|---| | find(code) | { city, placeName, state, stateCode, county, country, latitude, longitude, isValid } | | findState(code) | { state, stateCode, country, isValid } | | findCity(code) | { city, isValid } | | findCounty(code) | { county, isValid } | | findCoordinates(code) | { latitude, longitude, isValid } | | isValid(code) | boolean | | countryOf(code) | "US" | "CA" | null | | findByCity(city, stateCode) | ZipCodeInfo[] | | findByCounty(county, stateCode) | ZipCodeInfo[] | | findByRadius(lat, lng, radius, unit?) | ZipCodeInfo[], nearest first | | getStates(country?) | [{ code, name, country }] | | getProvinces() | Canadian provinces and territories |

findByCity("Boston", "MA")
findByCity("Vancouver", "BC")
findByCounty("Los Angeles", "CA")
findByRadius(45.5017, -73.5673, 5, "km")   // "km" or "mi"; defaults to "mi"
getStates("US")
getProvinces()

State and province codes never collide, so findByCity and findByCounty need no country argument.

"CA" is California's state code, not Canada's. Country codes appear only in the country field and in getStates(country).

TypeScript

import { find, type ZipCodeInfo, type Country } from "zipcodes-plus"

Exported types: ZipCodeInfo, ZipLookupResult, StateResult, Coordinates, Country, DistanceUnit.

Credits and licence

A fork of zipcodes-us by Karthik Gangadharaiah, with Canadian postal code support added.

Postal code data from GeoNames, licensed CC BY 4.0.

Code is MIT. See LICENSE.