topojson-client

Convert TopoJSON topologies to GeoJSON, merge shapes, and build meshes for map rendering

Library
npm
v3.1.0
238stars
ISC

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
40/100Fair
Development Activity0
Maintenance20
Community60
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
66/100Good
Architecture70
Code Quality62
Innovation68
Learning Curve65

topojson-client is the reference JavaScript library for working with TopoJSON, the compact topology-preserving alternative to GeoJSON created by Mike Bostock. It converts TopoJSON objects back into standard GeoJSON Features and FeatureCollections so they can be rendered with tools like d3.geoPath, while also providing shape-merging (to dissolve interior borders between adjacent polygons, such as states into a country outline), mesh extraction (for efficiently stroking shared boundaries only once), neighbor detection, and coordinate quantization utilities.

Because TopoJSON encodes shared boundaries as arcs referenced by multiple geometries rather than duplicating coordinates, files are dramatically smaller than equivalent GeoJSON — often 80% or more — which makes topojson-client a common companion to D3-based choropleths, boundary maps, and any browser application that needs to ship geographic topology efficiently and reconstitute it on the client.

What You Get

  • feature() to convert a TopoJSON object or GeometryCollection back into a GeoJSON Feature or FeatureCollection
  • merge() / mergeArcs() to dissolve interior borders and union adjacent Polygon/MultiPolygon objects into a single MultiPolygon
  • mesh() / meshArcs() to extract a deduplicated MultiLineString of arcs for efficient boundary stroking, with an optional filter for interior-vs-exterior borders
  • neighbors() to compute the adjacency list between a set of topology objects
  • bbox(), quantize(), transform()/untransform() for bounding boxes and delta-encoded coordinate quantization
  • CLI tools topo2geo, topomerge, and topoquantize for converting and manipulating TopoJSON files from the command line

Common Use Cases

  • Rendering choropleth maps and administrative boundaries with D3’s d3.geoPath after converting TopoJSON to GeoJSON with feature()
  • Producing a single country/region outline from many adjacent state or district polygons via merge()
  • Drawing map borders efficiently by stroking a mesh() once instead of every shared edge from every adjacent polygon
  • Preprocessing large geographic datasets on the command line with topo2geo/topoquantize before bundling them for a web app

Under The Hood

Architecture — The library is organized as one small ES module per operation (feature.js, merge.js, mesh.js, neighbors.js, quantize.js, transform.js, bbox.js) re-exported from a single src/index.js barrel, with no shared class or mutable global state; each function takes a TopoJSON topology object plus its own arguments and returns plain GeoJSON/TopoJSON data. feature.js exposes an internal object() walker that resolves TopoJSON arc indices into coordinate arrays via a transform() closure and reverses negative (backward-traversed) arc indices; merge.js and mesh.js both build on a shared stitch.js routine that joins raw arc fragments into closed rings or open lines using start/end-point dictionaries (fragmentByStart/fragmentByEnd), and merge.js additionally groups adjacent polygons via a Polygon-by-arc adjacency map before computing which grouped ring has the largest planar area to select the true exterior. Tech Stack — Pure JavaScript (ES2015 modules) with zero runtime dependencies for the library itself; the three CLI binaries in bin/ depend only on commander@2 for argument parsing and stream topology JSON from stdin/file through Node’s fs and readline. The build uses Rollup (rollup.config.js) to produce UMD/ESM bundles for browser, AMD, and CommonJS consumption, published to npm and unpkg/jsDelivr as dist/topojson-client.js. Code Quality — Tests live under test/*-test.js using tape, covering feature, merge, mesh, neighbors, quantize, bbox, and the topo2geo CLI (10 test files against real GeoJSON/TopoJSON fixtures in test/geojson and test/topojson), and eslint:recommended is enforced as part of the test script; the source itself favors terse, single-purpose functions with minimal inline documentation (relying on the README’s API reference instead), and there is no TypeScript — types are implicit from usage. API Design — The API is deliberately small and composable: every transform accepts a topology first and either an object/array/filter after, mirroring D3’s functional style, so feature, merge, and mesh can be reached for immediately after import * as topojson from "topojson-client" with no configuration or setup step; the tradeoff is that consumers must already understand TopoJSON’s arc/transform model to interpret arguments like arc filters or quantization transforms correctly.

Used by 5 apps in this directory

TypeScript
96%
Other

Lightdash

Analytics · Data Engineering

6,056

The open-source Looker alternative that turns your dbt project's metrics and dimensions into governed, self-serve charts and dashboards — no license key required.

View details
93
Repo Health
84
Technical
66
Dependency
Built with
TypeScript96%
Updated today
TypeScript
76%
MIT

OpenCode

AI Code Assistants

198,979

A fully open-source AI coding agent built for the terminal, with a TUI, desktop app, web client, plugin system, and SDK — one of the most-starred AI coding agents on GitHub.

View details
89
Repo Health
76
Technical
68
Dependency
Built with
TypeScript76%
MDX21%
Updated today
TypeScript
99%
AGPL 3.0

Pangolin

Networking

22,378

An open-source, identity-based zero-trust remote access platform built on WireGuard — a self-hostable alternative to Cloudflare Tunnel and Twingate with SSO, OIDC, and tunneled reverse proxying.

View details
87
Repo Health
68
Technical
72
Dependency
Built with
TypeScript99%
Updated today
Elixir
80%
AGPL 3.0

Plausible Analytics

Analytics

28,658

Open-source, cookie-free web analytics that respects visitor privacy and replaces Google Analytics.

View details
88
Repo Health
84
Technical
71
Dependency
Built with
Elixir80%
TypeScript14%
Updated yesterday
TypeScript
52%
Other

World Monitor

Monitoring · Analytics

83,076

Real-time global intelligence dashboard that fuses AI-synthesized news, geopolitical risk scoring, and infrastructure tracking into one open-source situational awareness platform.

View details
86
Repo Health
89
Technical
71
Dependency
Built with
TypeScript52%
JavaScript45%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search