@mapbox/vector-tile
Parse Mapbox Vector Tiles in JavaScript and access their layers and features as GeoJSON.
Repository Health
Technical Analysis
@mapbox/vector-tile reads binary Mapbox Vector Tiles (MVT) in JavaScript and exposes their layers and features for inspection. Given a protobuf-decoded tile buffer, it lets you enumerate layers, count and access features, read feature properties and geometry, and convert features to GeoJSON in geographic coordinates.
The library is a foundational building block of the vector-tile ecosystem, used by renderers, analysis tools, and tile servers to decode the compact MVT format into usable geometry. It depends on pbf for protobuf reading and point-geometry for coordinate types.
What You Get
- A
VectorTileclass that decodes an MVT buffer into named layers - Per-layer feature access with
lengthandfeature(i)accessors - Feature geometry loading and
toGeoJSON(x, y, z)conversion to geographic coordinates - Access to feature properties, IDs, and geometry types
Common Use Cases
- Decoding vector tiles for custom map renderers
- Extracting features from tiles for spatial analysis or conversion to GeoJSON
- Inspecting and debugging vector tile contents in tooling and pipelines
Under The Hood
Architecture
The library is organized as a small set of classes: VectorTile reads the top-level protobuf message and builds a map of VectorTileLayer objects; each layer lazily decodes VectorTileFeature instances on demand. Features decode their zig-zag-encoded command geometry into point arrays and can project those to WGS84 via toGeoJSON using the tile’s coordinate and extent. Protobuf parsing is delegated to the pbf reader.
Tech Stack
Written in JavaScript, depending on pbf (v5+) for fast protobuf decoding, @mapbox/point-geometry for point types, and @types/geojson for typings. Distributed as an ES module with a VectorTile named export.
Code Quality
A mature, widely-depended-upon library (millions of weekly downloads) with a focused test suite and Mapbox governance. Lazy feature decoding keeps memory and CPU costs proportional to what the caller actually reads.
API Design
The API mirrors the MVT data model closely — tile, layers, features — which makes it intuitive for anyone familiar with the format. The two-step pattern of decoding with pbf and wrapping in VectorTile is well documented, and toGeoJSON provides a convenient bridge to standard tooling.