How to Fix Invalid GeoJSON

Published · Last updated

Diagnose GeoJSON errors that can interrupt data exchange between GIS tools, APIs, maps and logistics software.

Try it now: GeoJSON validator

Two kinds of error

"Invalid GeoJSON" covers two different problems, and they are fixed in different ways.

  • JSON syntax errors mean the text is not valid JSON at all: a trailing comma, a missing quote or an unbalanced bracket. Nothing can read the file until these are fixed.
  • GeoJSON structure errors mean the text parses as JSON but does not follow the GeoJSON rules in RFC 7946: a missing type, a polygon ring that is not closed, or coordinates nested at the wrong depth.

Fix syntax errors first, because structure can only be checked once the JSON parses. In a software or logistics data pipeline, validating at import time can help catch malformed records before a downstream map or service tries to read them.

Step-by-step process

  1. Open the GeoJSON validator.
  2. Paste the document, or upload a .json or .geojson file.
  3. Press Validate.
  4. If the text is not valid JSON, correct the punctuation and validate again.
  5. If the document is reported invalid, use each reported error and its location in the document to find the member to correct. Fix one problem at a time and validate again, because one mistake can cause several messages.
  6. Once the document validates, continue to the checks in the final section.

Common mistakes and fixes

Trailing comma (JSON syntax)

Invalid, because JSON does not allow a comma after the last member:

{ "type": "Point", "coordinates": [12.5, 55.7], }

Fixed:

{ "type": "Point", "coordinates": [12.5, 55.7] }

Polygon ring that is not closed

A polygon ring must have at least four positions, and the first and last position must be identical. This ring stops one position short:

{ "type": "Polygon",
  "coordinates": [[[12.0, 55.0], [12.5, 55.0], [12.5, 55.5], [12.0, 55.5]]] }

Fixed by repeating the first position at the end:

{ "type": "Polygon",
  "coordinates": [[[12.0, 55.0], [12.5, 55.0], [12.5, 55.5], [12.0, 55.5], [12.0, 55.0]]] }

Wrong coordinate nesting

A Polygon's coordinates is an array of rings, and each ring is an array of positions. Writing only one level of ring is a structural mistake:

"coordinates": [[12.0, 55.0], [12.5, 55.0], [12.5, 55.5], [12.0, 55.0]]

Fixed by adding the outer array of rings:

"coordinates": [[[12.0, 55.0], [12.5, 55.0], [12.5, 55.5], [12.0, 55.0]]]

Missing required members

Every GeoJSON object needs a type. A Feature also needs a geometry and a properties member; RFC 7946 allows the value of either to be null. This Feature has no properties:

{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [12.5, 55.7] } }

Fixed:

{ "type": "Feature", "properties": {}, "geometry": { "type": "Point", "coordinates": [12.5, 55.7] } }

Coordinate order

GeoJSON positions are [longitude, latitude]. A point for central Manhattan is [-73.9857, 40.7484]. If you write [40.7484, -73.9857], the structure is still valid, but the point is placed near Antarctica instead of New York. If a latitude value falls outside −90 to 90 after swapping, the data is invalid; if it stays in range, the validator may report nothing and the problem only shows when you look at the map.

After the data validates

A successful validation confirms the document follows the checks performed by the validator; it does not confirm that every location is correct for your operation, that a coordinate reference system was interpreted as intended, or that a delivery address is valid. Review the data against its source and business rules as well.

The API also provides GeoJSON validation for applications that need to check documents programmatically. See the API overview and its documentation.

Tools used in this guide

Related guides

Browse all technical guides