# @mapbox/vector-tile

> Parses vector tiles

Latest version **3.0.0** (published 2026-05-27) · BSD-3-Clause license · 6.1M weekly downloads

## Install

```sh
npm install @mapbox/vector-tile
pnpm add @mapbox/vector-tile
yarn add @mapbox/vector-tile
bun add @mapbox/vector-tile
```

## Health

**Score 85/100 (A)** — status: active.

Positive: high downloads; has types; esm support; no vulnerabilities; high maintenance score; high quality score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2026-05-27 |
| First published | 2016-08-11 |
| Weekly downloads | 6.1M |
| License | BSD-3-Clause |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 17.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 405 |
| Maintainers | mapbox-npm-01, mapbox-npm-02, mapbox-npm-07, mapbox-npm-03, mapbox-npm-04, mapbox-npm-09, mapbox-npm-05, mapbox-npm-06, mapbox-npm-08, mapbox-npm-advanced-actions, mapbox-npm-ci, mapbox-npm, mapbox-admin, mapbox-machine-user, mbx-npm-ci-staging, mbx-npm-ci-production, mbx-npm-01-production, mbx-npm-02-production, mbx-npm-03-production, mbx-npm-04-production, mbx-npm-05-production, mbx-npm-06-production, mbx-npm-07-production, mbx-npm-08-production, mbx-npm-09-production, mbx-npm-02-staging, mbx-npm-advanced-actions-staging, mbx-npm-advanced-actions-production |

## Links

- npm: https://www.npmjs.com/package/@mapbox/vector-tile
- Repository: https://github.com/mapbox/vector-tile-js
- Homepage: https://github.com/mapbox/vector-tile-js#readme
- Issues: https://github.com/mapbox/vector-tile-js/issues
- npm.io page: https://npm.io/package/@mapbox/vector-tile

## Dependencies (3)

- [pbf](https://npm.io/package/pbf.md) ^5.0.0
- [@types/geojson](https://npm.io/package/@types/geojson.md) ^7946.0.16
- [@mapbox/point-geometry](https://npm.io/package/@mapbox/point-geometry.md) ~1.1.0

## Recent versions

- 3.0.0 (latest) — 2026-05-27
- 2.0.5 — 2026-05-26
- 2.0.4 — 2025-06-18
- 2.0.3 — 2024-07-16
- 2.0.2 — 2024-07-12
- 2.0.1 — 2024-07-11
- 2.0.0 — 2024-07-11
- 1.3.1 — 2018-03-03
- 1.3.0 — 2017-04-21
- 1.0.0-alpha.1 — 2016-08-26
- 1.0.0-rc3 — 2016-08-22
- 1.0.0-rc2 — 2016-08-12
- 1.0.0-rc1 — 2016-08-11

## README

# vector-tile

This library reads [Mapbox Vector Tiles](https://github.com/mapbox/vector-tile-spec) and allows access to the layers and features.

## Example

```js
import {VectorTile} from '@mapbox/vector-tile';
import Protobuf from 'pbf';

const tile = new VectorTile(new Protobuf(data));

// Contains a map of all layers
tile.layers;

const landuse = tile.layers.landuse;

// Amount of features in this layer
landuse.length;

// Returns the first feature
landuse.feature(0);
```

Vector tiles contained in [serialtiles-spec](https://github.com/mapbox/serialtiles-spec)
are gzip-encoded, so a complete example of parsing them with the native
zlib module would be:

```js
import {VectorTile} from '@mapbox/vector-tile';
import Protobuf from 'pbf';
import {gunzipSync} from 'zlib';

const buffer = gunzipSync(data);
const tile = new VectorTile(new Protobuf(buffer));
```

## Install

To install:

    npm install @mapbox/vector-tile


## API Reference

### VectorTile

An object that parses vector tile data and makes it readable.

#### Constructor

- **new VectorTile(protobuf[, end])** &mdash;
  parses the vector tile data contained in the given [Protobuf](https://github.com/mapbox/pbf) object,
  saving resulting layers in the created object as a `layers` property. Optionally accepts end index.

#### Properties

- **layers** (Object) &mdash; an object containing parsed layers in the form of `{<name>: <layer>, ...}`,
where each layer is a `VectorTileLayer` object.


### VectorTileLayer

An object that contains the data for a single vector tile layer.

#### Properties

- **version** (`Number`, default: `1`)
- **name** (`String`) &mdash; layer name
- **extent** (`Number`, default: `4096`) &mdash; tile extent size
- **length** (`Number`) &mdash; number of features in the layer

#### Methods

- **feature(i)** &mdash; get a feature (`VectorTileFeature`) by the given index from the layer.


### VectorTileFeature

An object that contains the data for a single feature.

#### Properties

- **type** (`Number`) &mdash; type of the feature (also see `VectorTileFeature.types`)
- **extent** (`Number`) &mdash; feature extent size
- **id** (`Number`) &mdash; feature identifier, if present
- **properties** (`Object`) &mdash; object literal with feature properties

#### Methods

- **loadGeometry()** &mdash; parses feature geometry and returns an array of
  [Point](https://github.com/mapbox/point-geometry) arrays (with each point having `x` and `y` properties)
- **bbox()** &mdash; calculates and returns the bounding box of the feature in the form `[x1, y1, x2, y2]`
- **toGeoJSON(x, y, z)** &mdash; returns a GeoJSON representation of the feature. (`x`, `y`, and `z` refer to the containing tile's index.)

---
_Source: https://npm.io/package/@mapbox/vector-tile · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
