Skip to content
convert latitude longitude coordinate pairs to US zip codes
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test switched to kd tree
.gitignore add intellij project file to gitignore
.npmignore Got it ready for NPM.
LICENSE switched to MIT license switched to kd tree
package.json make package name lowercase
sort.js cleaned up input data, deleted old boilerplate
zip_codes_sorted.json added improved input file


Convert GPS latitude longitude pairs to a US zip code.

Quick Start

npm install gps2zip


var gps = require('gps2zip');
var latitude = 30.2669;
var longitude = 97.7428;
gps.gps2zip(latitude, longitude);
// returns 78701

Unit tests

node tests/basic.js


The output is approximate. The source data is just a list of coordinates, not actual boundaries. The algorithm just finds the minimum euclidean distance between the point in question and the known points. No error checking for points outside the United States.


You can get full street addresses using the Google Maps Reverse Geocoding API:


Zip codes from The Zip Code Database Project

Something went wrong with that request. Please try again.