geojsonkit.org
GeoJSON utilities, in the browser
Say hi →

Clip GeoJSON to a bounding box

Take a country-sized file down to the city you are actually rendering. Give it four numbers and it cuts every polygon and line at the boundary, or — if you would rather not touch the geometry — keeps whole features that intersect the box or fall entirely inside it.

Clip GeoJSON to a bounding box

updated 26 August 2026

Drop a .geojson file, or

What this tool does

It restricts a GeoJSON document to a rectangle in longitude/latitude. In the default mode the geometry itself is cut: a coastline that leaves the window is truncated at the edge, a polygon that straddles the boundary comes back as the part inside it, and anything wholly outside is dropped. In the two keep whole features modes nothing is edited — features are selected or rejected by whether they touch the box.

The intent it closes: "this file covers a whole country and I am rendering one city." Clipping is usually the single biggest size reduction available to a web map, and doing it normally means installing a GIS or uploading the file to something. This runs in the page, so a 60 MB file is only as slow as your laptop.

How this tool works

One pass over the features, one rejection test and one clipping algorithm per geometry kind.

1. Read the box

Four numbers, separated by commas or spaces, in the GeoJSON bbox order: minLng, minLat, maxLng, maxLat. The two latitudes are sorted for you, so a box entered corner-swapped still works. The two longitudes are not — see the antimeridian below, where west greater than east is meaningful rather than a typo. Values outside −180…180 or −90…90 are refused rather than silently clamped — almost always it means the pair was pasted lat-first. Fit to data fills the field with the bounding box of what you pasted, which is a much easier thing to shrink than an empty field is to fill.

2. Reject what cannot possibly survive

Each feature's own bounding box is compared with the window first. Non-overlapping features are dropped without any geometry work, and features entirely inside are passed through untouched — no rounding, no re-emission, byte-identical coordinates. Only the ones that straddle the edge are actually clipped.

The box test is used as a filter and never as an answer: two rectangles can overlap while the shapes inside them do not touch at all. Anything the box test lets through is then decided by the clipper itself, which computes the surviving part exactly — including the case where the window sits wholly inside a polygon and not one vertex of either is inside the other.

3. Cut what is left

Points are a containment test. Lines are cut with the Liang–Barsky algorithm segment by segment, and the surviving runs are kept separate — a road that leaves the window and comes back returns as a MultiLineString with two parts, not one line that leaps across the gap. Polygon rings are clipped with Sutherland–Hodgman against the four edges in turn, which is exact for a convex clip window.

The exterior ring is clipped first and on its own. If it does not survive the window, nothing inside it does either — the holes go with it. Only then are the interior rings clipped, each independently, and appended after it. Order matters here more than it looks: a GeoJSON reader takes ring 0 for the outline and every later ring for a hole, so a hole that reaches position 0 is read as the shape. If the surviving holes account for the whole of the surviving exterior — which is what a window sitting entirely inside a doughnut's hole produces — the feature is dropped rather than emitted as a zero-area ring pair.

Options

Mode

Cut geometry at the boundary is the real clip, and the only mode that reduces the size of a large polygon. Keep whole features that intersect selects without editing — right when the features are meaningful units (a building, a parcel, an administrative area) and half of one is worse than none. Keep whole features fully inside is the strict version, useful when you are going to compute statistics and do not want partial shapes skewing them.

A box that crosses the antimeridian

RFC 7946 §5.2 says a bounding box whose west value is greater than its east value crosses the 180° meridian. 170, -10, -170, 10 is the strip of Pacific either side of the date line, not an error and not the rest of the world. Sorting that pair with min/max — which is the obvious thing to do, and what this tool used to do — turns it into -170, -10, 170, 10: the exact complement of what was asked for, with no warning.

Type the pair in that order and the box is now clipped as two windows, 170…180 and -180…-170, with the surviving pieces merged back into one geometry per feature. The status line says so explicitly whenever it happens, so you can tell a deliberate Pacific box from a corner-swapped one.

Minify output

Off by default so the result is readable. On, the output is a single line — that plus clipping is usually where the file-size win comes from. The status line reports both sizes compared minified-to-minified, so the percentage measures the clip rather than the indentation.

Example

A line crossing the window twice, clipped to 0, 0, 10, 10:

{"type":"LineString",
 "coordinates":[[-5,5],[5,5],[15,5],[15,8],[5,8]]}

Output:

{"type":"MultiLineString",
 "coordinates":[[[0,5],[5,5],[10,5]],[[10,8],[5,8]]]}

Two separate runs, each cut exactly at longitude 0 and 10. Joining them back into one line would draw a segment straight across the excluded middle.

Tips & common pitfalls

  • Get the box from the map, not from memory. Bounding box reports the extent of any file, and most map libraries will print the current view's bounds. Paste those four numbers here.
  • Clipping is not the same as simplifying. Cutting the extent removes features; simplify removes vertices from the ones that remain. On a heavy file you usually want both, in that order.
  • Cut polygons trace the box edge. That is what clipping means — the new boundary follows the rectangle. If those straight edges are wrong for your purpose, use one of the keep whole features modes instead.
  • Properties are preserved as-is. A clipped feature keeps every property and its id. Any property holding a measurement — area, length, a population density — is now wrong for the shape it is attached to; re-run area & length afterwards.

FAQ

Does it clip against an arbitrary polygon, not just a rectangle?

No. The window is a rectangle in longitude/latitude, which is what Sutherland–Hodgman is exact for. Clipping against an arbitrary — possibly concave — polygon needs a general boolean-intersection engine; for selecting points by an arbitrary shape, point in polygon does that already.

Why did "keep whole features that intersect" used to keep too much?

It compared bounding boxes. A diagonal road from 0,0 to 10,10 has a bounding box that overlaps a window at 8,0 – 10,2, but the road never enters it. The mode now runs the real clip and keeps the untouched feature whenever the clip produces anything, so the selection is exact for every geometry type here.

Is the cut geodesic?

No, and it should not be. The edges of the box are lines of constant longitude and latitude, and the cut points are found by linear interpolation in degrees — which is exactly where the boundary lies. Measurement is a separate question; area & length is geodesic.

What happens to elevation?

It is interpolated along with the coordinates. A track cut halfway between a 180 m point and a 190 m point gets 185 m at the boundary, so an elevation profile stays continuous.

What if nothing survives?

You get an empty FeatureCollection and a status line saying 0 of N features were kept. That is a valid document — it is usually a sign the box was entered lat-first.