How to Find the Bounding Box of GeoJSON Data

API or service
Geometry Operations API
Task
GeoJSON geometry → west/south/east/north bounds
Examples
URL
Difficulty
Beginner
Time
5 min

Find the bounding box of GeoJSON data

You have a GeoJSON geometry and need the smallest axis-aligned rectangle containing every coordinate. The Geometry Operations API bbox operation returns both the four numeric bounds and a Polygon that can be displayed or processed.

Task flow: GeoJSON geometry → bounding box → map viewport or spatial filter.

The returned array uses [west, south, east, north], equivalent to [minimum longitude, minimum latitude, maximum longitude, maximum latitude]. This is not the same as two [latitude, longitude] pairs.

Calculate the bounding box

POST https://api.geoapify.com/v1/geometry/operation?apiKey=YOUR_API_KEY
Content-Type: application/json
{
  "operation": "bbox",
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [13.38, 52.50], [13.42, 52.50],
      [13.42, 52.54], [13.38, 52.54],
      [13.38, 52.50]
    ]]
  },
  "params": {
    "recompute": true
  }
}

Reduced response: The same bounds also appear in data.properties.bbox; the Polygon is retained here to show the result geometry.

{
  "type": "geojson",
  "data": {
    "type": "Feature",
    "bbox": [13.38, 52.50, 13.42, 52.54],
    "properties": {
      "bbox": [13.38, 52.50, 13.42, 52.54]
    },
    "geometry": {
      "type": "Polygon",
      "coordinates": [[
        [13.38, 52.50], [13.42, 52.50],
        [13.42, 52.54], [13.38, 52.54],
        [13.38, 52.50]
      ]]
    }
  }
}

For MapLibre GL, convert the array to [[west, south], [east, north]] before calling fitBounds. A normal bounding box may need special handling when a geometry crosses the antimeridian.