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

geo-codec-offline

v1.0.1

Published

Zero-dependency offline geocoding library for India — forward geocode, reverse geocode, fuzzy search, and bounding-box queries. No internet required.

Readme

geo-codec-offline

Offline geocoding for India. No internet. No API key. No limits.

Look up Indian cities by name, find the nearest city to any coordinates, search by state, and more — all from your local machine.


Install

npm install geo-codec-offline

Usage

In your Node.js project

const { geocode, reverseGeocode, search, searchByState, bbox, stats } = require('geo-codec-offline');

1. Forward Geocode — City name → Coordinates

const city = geocode('Mumbai');
console.log(city);
// {
//   name: 'Mumbai',
//   latitude: 18.9667,
//   longitude: 72.8333,
//   state: 'Maharashtra',
//   stateCode: 'MH',
//   population: 12691836,
//   country: 'India'
// }

Works with partial names and typos too:

geocode('Banga');              // → Bangalore (prefix match)
geocode('Mumbi', { fuzzy: true }); // → Mumbai (typo-tolerant)

2. Reverse Geocode — Coordinates → Nearest City

const result = reverseGeocode(19.07, 72.87);
console.log(result.name);            // → 'Mumbai'
console.log(result.distance.value);  // → 12.3
console.log(result.distance.unit);   // → 'km'

Get distance in miles:

reverseGeocode(19.07, 72.87, { unit: 'mi' });

3. Search — Autocomplete / Prefix Search

const results = search('Hyder', { limit: 5 });
// → [{ name: 'Hyderabad', ... }, ...]

With fuzzy matching (finds results even with typos):

search('Chenai', { fuzzy: true });
// → [{ name: 'Chennai', ... }]

4. Search by State — All Cities in a State

searchByState('Kerala');   // full state name
searchByState('KL');       // 2-letter state code
searchByState('Pradesh');  // partial match — finds all Pradesh states

Returns cities sorted by population (largest first).


5. Bounding Box — Cities Within a Region

const cities = bbox({
  minLat: 15.6,
  maxLat: 22.1,
  minLon: 72.6,
  maxLon: 80.9
});
// → all cities inside Maharashtra's rough boundary

6. Stats — Dataset Info

const info = stats();
// { total: 177, source: 'GeoNames / curated', coverage: 'India', version: '1.0.0' }

CLI — Use Without Writing Code

# Forward geocode
npx geo-codec-offline "Delhi"

# Reverse geocode
npx geo-codec-offline --reverse 28.65 77.23

# Prefix search
npx geo-codec-offline --search "Nag" --limit 5

# All cities in a state
npx geo-codec-offline --state "Rajasthan"
npx geo-codec-offline --state RJ

# Bounding box
npx geo-codec-offline --bbox 15.6 22.1 72.6 80.9

# Dataset info
npx geo-codec-offline --stats

# Typo-tolerant search
npx geo-codec-offline "Bangalor" --fuzzy

# JSON output (pipe-friendly)
npx geo-codec-offline "Pune" --json

ES Module Support

import { geocode, searchByState } from 'geo-codec-offline';

Why This Package?

Most geocoding tools need an internet connection and an API key with usage limits.
This package bundles the data locally — it works offline, always, for free.

  • ✅ Zero dependencies
  • ✅ Works in Node.js 16+
  • ✅ Supports both require() and import
  • ✅ 177 Indian cities across all states and UTs
  • ✅ Fuzzy (typo-tolerant) search built in
  • ✅ KD-Tree for fast nearest-city lookup

License

MIT © Karthik Karra