Format a GeoJSON Feature Collection
GeoJSON is the standard format for geographic data in web maps and spatial APIs. This example shows a FeatureCollection with a Point and a Polygon, which are the two most common geometry types. Formatting makes it easy to spot misplaced brackets around coordinate arrays, which are the most frequent source of map rendering bugs. Validate before importing into Leaflet, Mapbox, or a PostGIS database.
Example
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [-73.9857, 40.7484] },
"properties": { "name": "Empire State Building" }
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [[[-74.0, 40.7], [-73.9, 40.7], [-73.9, 40.8], [-74.0, 40.8], [-74.0, 40.7]]]
},
"properties": { "name": "Manhattan Area" }
}
]
}FAQ
- What coordinate order does GeoJSON use?
- GeoJSON always uses [longitude, latitude] order — the opposite of many mapping APIs. This is a frequent source of bugs where points appear in the wrong hemisphere.
- How do I close a GeoJSON polygon?
- The last coordinate in a Polygon ring must be identical to the first coordinate. This closes the ring; omitting it causes rendering issues in some parsers.
- Can GeoJSON store custom properties?
- Yes. Each Feature has a properties object where you can store any key-value data you want associated with that geometry.
Related Examples
Format a REST API Response
REST APIs return compact JSON that is hard to read at a glance. Paste this examp...
Explore Deeply Nested JSONDeep nesting is common in configuration files, CMS payloads, and analytics event...
Convert JSON Array to CSVA JSON array of objects is the most common format for tabular data returned by A...