Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Node.js API that converts gps coordinate pairs to US zip codes

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 bin
Octocat-spinner-32 public
Octocat-spinner-32 views
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .npmignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 demo.js
Octocat-spinner-32 package.json
Octocat-spinner-32 server.js
Octocat-spinner-32 zips.csv
Octocat-spinner-32 zips.json


Convert GPS latitude longitude pairs to a US zip code.

Runs as a server-side node API for your client-side js applications.

Quick Start

npm install Gps2zip
cd node_modules/Gps2zip/
node demo.js

Example usage of demo app

Start the demo app

node demo.js

Access the REST API with curl:

burt$ curl "localhost:4000?lat=30.2859283&lon=-97.7461031"
    "zip code":"78705",
    "state abbreviation":"TX",
    "latitude":" 30.292424",
    "longitude":" -97.73856",

Or from jQuery:

var lat = 30.2859283;
var lon = -97.7461031;
$.get("/?lat=" + lat + "&lon=" + lon, function(res){
    if(res.error != undefined){
    } else {
        console.log(res["zip code"]);

Open /demo in the browser for a more user-friendly demo.

Using gps2zip in your own application

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


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


All other work is The Unlicense (Public Domain)

Something went wrong with that request. Please try again.