JavaScript geospatial libraries

Updated Nov 2026

JavaScript geospatial libraries measure, transform, and analyze geographic coordinates and shapes. A coordinate system defines how each longitude and latitude maps to a position on the Earth or on a flat map. These libraries calculate the distances, delivery zones, map projections, and boundary checks in mapping and location apps.

Popularity

d3-geo has the most monthly downloads in this comparison, at 205.4M.

LibraryMonthly downloadsStarsLast releaseLicense
d3-geo
205.4M
1.1KNov 2026ISC
TopoJSON Client
44.8M
242Nov 2019ISC
Proj4js
9.1M
2.2KNov 2026MIT
cheap-ruler
9.1M
434Oct 2026ISC
Turf
9.0M
10.6KAug 2026MIT
h3-js
8.0M
1.1KJul 2026Apache-2.0
JSTS
7.7M
1.6KNov 2024(EDL-1.0 OR EPL-1.0)
Geolib
3.1M
4.3KNov 2026MIT
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Calculates shapes and measurements for spherical coordinates.

Downloads / mo
205.4M
Stars
1.1K
Last release
3.1.2
License
ISC

Strengths

  • Projects onto a flat map. Projections turn spherical polygons into planar polygons for drawing.

Limitations

  • Clipped points return null. Check for null when a point falls outside the projection's clipping bounds.

Quickstart

From math docs
$ npm install d3-geo@3.1.2
import { geoDistance } from "d3-geo";
console.log(geoDistance([0, 0], [1, 0]));

d3-geo examples

From open-source projects on GitHub

TopoJSON Client

Manipulates TopoJSON and converts it to GeoJSON.

Downloads / mo
44.8M
Stars
242
Last release
3.1.0
License
ISC

Strengths

  • Merges and quantizes shapes. Merge shapes or quantize coordinates before converting back to GeoJSON.

Quickstart

From README.md
$ npm install topojson-client@3.1.0
import { feature } from "topojson-client";
const topology = { type: "Topology", objects: { place: { type: "Point", coordinates: [0, 0] } }, arcs: [] };
console.log(feature(topology, topology.objects.place));

TopoJSON Client examples

From open-source projects on GitHub

Converts point coordinates between coordinate systems, including datum transformations.

Downloads / mo
9.1M
Stars
2.2K
Last release
2.23.0
License
MIT

Strengths

  • Converts between coordinate systems. Supply source and target definitions to transform point coordinates.
  • Reuses forward and inverse converters. Create a converter once and use both transformation directions.

Limitations

  • Grid adjustments need loaded files. Load the required grid before using its datum transformation.
  • Defaults to longitude before latitude. Set enforceAxis when coordinates follow the definition’s different axis order.

Quickstart

From README.md
$ npm install proj4@2.23.0
import proj4 from "proj4";
console.log(proj4("EPSG:4326", "EPSG:3857", [0, 0]));

Proj4js examples

From open-source projects on GitHub

Approximates common geographic measurements.

Downloads / mo
9.1M
Stars
434
Last release
4.1.1
License
ISC

Strengths

  • Precise at city scale. Under 500 km and away from the poles, results stay within 0.1% of Vincenty's formulae.

Limitations

  • Reuse one ruler per area. Create a ruler once for an area and reuse it across calculations.

Quickstart

From README.md
$ npm install cheap-ruler@4.1.1
import CheapRuler from "cheap-ruler";
const ruler = new CheapRuler(50.5, "meters");
console.log(ruler.distance([30.5, 50.5], [30.51, 50.51]));

cheap-ruler examples

From open-source projects on GitHub
(a, b) =>
    ruler.lineDistance(a.geometry.coordinates) -
    ruler.lineDistance(b.geometry.coordinates)

Analyzes GeoJSON features with geographic measurements, geometry operations, and spatial tests.

Downloads / mo
9.0M
Stars
10.6K
Last release
7.4.0
License
MIT

Strengths

  • Works directly with GeoJSON. Create features and analyze their geometry without a separate geometry model.
  • Tests polygons with holes. booleanPointInPolygon handles concave shapes and polygon holes.

Limitations

  • Expects longitude before latitude. Use WGS84 coordinates in GeoJSON order before running geographic analysis.
  • Shrinking can remove features. A large negative buffer can return fewer geometries or an empty collection.

Quickstart

From README.md
$ npm install @turf/turf@7.4.0
import { distance } from "@turf/turf";
console.log(distance([0, 0], [1, 0], { units: "kilometers" }));

Turf examples

From open-source projects on GitHub

Provides a pure JavaScript version of H3, a hexagon-based geographic grid system.

Downloads / mo
8.0M
Stars
1.1K
Last release
4.5.0
License
Apache-2.0

Strengths

  • Indexes points into hexagons. latLngToCell turns a latitude and longitude into a hexagon index at a chosen resolution.

Limitations

  • Function names changed in v4. Code written for H3 v3 needs the renamed v4 functions.

Quickstart

From README.md
$ npm install h3-js@4.5.0
import { latLngToCell } from "h3-js";
console.log(latLngToCell(37.3615593, -122.0553238, 7));

h3-js examples

From open-source projects on GitHub

Processes geometries and spatial relationships using the JTS geometry model.

Downloads / mo
7.7M
Stars
1.6K
Last release
2.12.1
License
(EDL-1.0 OR EPL-1.0)

Strengths

  • Connects to OpenLayers geometries. Read and write OpenLayers geometries through its direct parser.
  • Reads WKT and GeoJSON. Use either geometry format when exchanging shapes with other tools.

Limitations

  • Precision errors can stop operations. Validate inputs and reduce coordinate precision when geometry calculations fail.
  • Requires operation classes for methods. Use the operation class instead of calling geometry.buffer in ES modules.

Quickstart

From index_modules.js
$ npm install jsts@2.12.1
import GeoJSONReader from "jsts/org/locationtech/jts/io/GeoJSONReader.js";
const reader = new GeoJSONReader();
console.log(reader.read({ type: "Point", coordinates: [0, 0] }));

JSTS examples

From open-source projects on GitHub

Calculates geographic distances, bearings, and location boundaries from coordinate pairs.

Downloads / mo
3.1M
Stars
4.3K
Last release
4.0.2
License
MIT

Strengths

  • Checks polygon boundaries directly. Use isPointInPolygon to check whether a location lies inside an outline.
  • Offers ellipsoid-based distance calculations. Use getPreciseDistance for Vincenty distance calculations on an ellipsoid.

Limitations

  • Ignores altitude and elevation. Distance and boundary calculations operate in two dimensions.
  • Polygon vertices need outline order. Supply vertices clockwise or counterclockwise around the polygon boundary.

Quickstart

From README.md
$ npm install geolib@4.0.2
import { getDistance } from "geolib";
console.log(getDistance({ latitude: 51.5103, longitude: 7.49347 }, { latitude: 51.525, longitude: 7.4575 }));

Geolib examples

From open-source projects on GitHub
export function inZone(location: locationData, zone: locationData): boolean {
    const { radius = 0, ...zoneLatLog } = zone;
    const inZone = isPointWithinRadius(location, zoneLatLog, radius);

    return inZone;
}

FAQ

Turf fits analysis of GeoJSON features, such as distances and point-in-polygon tests. Proj4js converts coordinates between coordinate systems, and d3-geo projects geographic shapes onto a flat map.

GeoJSON is a JSON format for geographic features such as points, lines, and polygons, each with its coordinates and properties. Turf and JSTS read GeoJSON directly.

Geolib calculates distances, bearings, and boundary checks from plain coordinate pairs. It works in two dimensions and ignores altitude.

h3-js is the pure JavaScript version of Uber's hexagon-based geographic grid system. Its latLngToCell function turns a latitude and longitude into a hexagon index at a chosen resolution.

Proj4js transforms point coordinates from one coordinate system to another, including datum transformations. It expects longitude before latitude unless enforceAxis is set.

TopoJSON stores geographic shapes with shared borders as arcs. TopoJSON Client converts TopoJSON back to GeoJSON for rendering with tools such as d3-geo.

For coding agents

Found your geospatial library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official