# @mapbox/geojson-extent

> compute the bounding box of geojson features

Latest version **1.2.0** (published 2026-11-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install @mapbox/geojson-extent
pnpm add @mapbox/geojson-extent
yarn add @mapbox/geojson-extent
bun add @mapbox/geojson-extent
```

Provides the command `geojson-extent`.

## Health

**Score 68/100 (B)** — status: active.

Positive: has types package; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2026-11-09 |
| First published | 2017-01-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/mapbox__geojson-extent) |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 25.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 73 |
| Author | Tom MacWright |
| 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 |
| Keywords | geojson, extent, browser, geo, boundingbox, bounds |

## Links

- npm: https://www.npmjs.com/package/@mapbox/geojson-extent
- Repository: https://github.com/mapbox/geojson-extent
- Issues: https://github.com/mapbox/geojson-extent/issues
- npm.io page: https://npm.io/package/@mapbox/geojson-extent

## Dependencies (4)

- [rw](https://npm.io/package/rw.md) ~0.1.4
- [neotraverse](https://npm.io/package/neotraverse.md) ^0.6.15
- [@mapbox/extent](https://npm.io/package/@mapbox/extent.md) 0.4.0
- [@mapbox/geojson-coords](https://npm.io/package/@mapbox/geojson-coords.md) 0.0.2

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2026-11-09
- 1.1.1-c2af7c0 (prerelease) — 2026-10-30
- 0.3.3-dev1 (dev) — 2020-09-21
- 1.0.1 — 2021-09-14
- 1.0.0 — 2020-09-21
- 0.4.0 — 2020-09-21
- 0.3.2 — 2017-01-22

## README

# geojson-extent

Compute an extent given a GeoJSON object.

## install

    npm install --save @mapbox/geojson-extent

## example

[Live example with Mapbox Static Map API](https://www.mapbox.com/mapbox.js/example/v1.0.0/static-map-from-geojson-with-geo-viewport/)

```js
var geojsonExtent = require('geojson-extent');

geojsonExtent({ type: 'Point', coordinates: [0, 0] }); // returns 0,0,0,0 extent
```

## bin

Provides a binary that takes GeoJSON as stdin and returns a JSON stringified
array of extent data.

```sh
$ npm install -g geojson-extent
$ geojson-extent < file.geojson
```

Given an argument of `leaflet`, this will return Leaflet-formatted data instead.

```sh
$ geojson-extent leaflet < file.geojson
```

## api

### `extent(geojson)`

Given any valid GeoJSON object, return bounds in the form `[WSEN]`.
Invalid objects will return `null`.

### `extent.polygon(geojson)`

Given any valid GeoJSON object, return bounds in the form of a GeoJSON polygon object.
Invalid objects will return `null`.

### `extent.bboxify(geojson)`

Add [bounding boxes](http://geojson.org/geojson-spec.html#bounding-boxes) to all
appropriate GeoJSON objects - Feature, FeatureCollection, and Geometry.

## Publishing

Pull Requests to `main` automatically publish a new version based on the PR's title prefix (`major:`, `minor:` or `patch:`) to the npmjs registry.

The published version in the registry is the source of truth for the package version, but you can manually increment the `package.json`'s `version`.

### Pre-release versions on other branches

For testing in downstream projects, you can manually trigger the "NPM release" workflow on a branch to publish a pre-release tagged with the short commit sha (e.g. `1.1.0-aa79c6a`) under the npm `prerelease` dist-tag, without affecting `latest`. Check the workflow results for the published version.

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