GeoJSON validator

Paste GeoJSON or drop a file to check it against RFC 7946. Every problem is explained in plain words with its line number, and most have a one-click fix. Free, no account needed.

Drop a GeoJSON file here

Download the sample

Your file stays on your computer: nothing is uploaded.

In short

A free GeoJSON validator and fixer that runs in your browser

The Spatibase GeoJSON validator checks GeoJSON against RFC 7946 in your web browser and explains each problem in plain words, with its line number. It fixes the common ones in one click (open rings, winding order, coordinates as text, a legacy crs member, too many decimals), shows the data on a map and tells you whether the file will import into Spatibase. It’s free with no account, checks files up to 50 MB, and nothing is uploaded.

What you get beyond a plain “invalid”:

  • Where, not just what. Each problem names its lines and a path such as features[12].geometry.
  • Fixes that check again. After a fix the text is checked anew, so the list and the map always match what you download.
  • Honest limits. Swapped coordinates that stay in range can’t be detected (the map shows them), and self-intersections are found, not fixed.
How to

How to validate GeoJSON

Paste, check, fix, download: all on this page.

  1. Press Paste GeoJSON, paste it and press Check (Ctrl+Enter or ⌘+Enter), or drop a .geojson file. No file? Open the sample: Barcelona places with typical mistakes.
  2. Read the list: errors, then warnings and notes, each with its lines.
  3. Press a problem’s fix, or Fix all. The text is checked again each time.
  4. Look at the map. A point on the wrong continent has longitude and latitude swapped: press Swap longitude and latitude.
  5. Download or copy the fixed GeoJSON, or press Save to Spatibase (free) to put it in a free Spatibase project.
What it checks

What the GeoJSON checker looks for, and how it fixes it

Three levels. Errors make the file invalid or stop it importing; warnings break an RFC 7946 recommendation or look wrong; notes are worth knowing.

The errors, and what each fix does:

  • Broken JSON. Line, column and likely cause (trailing comma, single quotes, a comment, NaN). When trailing commas, comments or a BOM are the only problems, one click removes them.
  • Not GeoJSON. A bare array of features is wrapped in a FeatureCollection; a type in the wrong case ("featurecollection") is recased.
  • Incomplete features. A bare geometry, or a Feature without geometry or properties (required, even as null): wrapped or completed.
  • Coordinates as text. "2.17" becomes 2.17.
  • Latitude outside ±90. Swapped back when swapping explains it.
  • Metres, not degrees. Web Mercator (EPSG:3857) is converted to WGS 84; other projections need exporting again.
  • Broken shapes. Open rings are closed. Lines under 2 positions, rings under 4 and positions that aren’t numbers can’t be repaired, so those features are removed and named. Extra values after the altitude are only noted.

Warnings are valid GeoJSON that software may still trip over:

  • Winding order. Rings against the right-hand rule are reversed.
  • A `crs` member. Dropped, since RFC 7946 removed it. Web Mercator is converted first; a crs naming another projection stays, as it’s the only record of what the numbers mean.
  • Longitude past ±180. Wrapped back onto the map.
  • GeometryCollection. Split into one Feature per member.
  • Self-intersections. A bow-tie ring is pointed to, not fixed: only you know the intended shape.
  • Smaller things. A bbox that doesn’t fit (dropped), odd ids, more than 10,000 features.

Notes change nothing by themselves. They mention null geometries, altitudes and duplicate ids, and offer Round to 6 decimals when there are more than 7.

Formats

Why valid JSON can still be broken GeoJSON

JSON is only the envelope. A JSON linter checks brackets and commas; GeoJSON adds rules about what goes inside, and map software needs them to hold.

The three that catch people out most:

  • Longitude first. [2.17, 41.38] is Barcelona; [41.38, 2.17] lands in East Africa, and both pass.
  • Degrees in WGS 84. There is no crs any more, so a file in metres can’t say what it is.
  • Closed rings. Four positions or more, the last equal to the first.

Will it import into Spatibase? The validator runs every geometry through the importer’s own code. The importer is kinder than the RFC: it closes rings, wraps longitudes, ignores winding, keeps 2D and rounds to 7 decimals. It skips GeometryCollections, latitudes past ±90 and too-short shapes, and takes up to 10,000 features.

For developers

Validate GeoJSON in code

check-geojson, the successor to Mapbox’s geojsonhint, parses the text and throws a list of problems; geojson-rewind fixes the winding.

import { check, HintError } from '@placemarkio/check-geojson'
import rewind from '@mapbox/geojson-rewind'

try {
  const geojson = check(text) // text: the file's contents as a string
  const fixed = rewind(geojson, false) // false: outer rings counter-clockwise (RFC 7946)
  console.log(JSON.stringify(fixed))
} catch (err) {
  if (!(err instanceof HintError)) throw err
  for (const issue of err.issues) console.log(issue.message)
}

With GDAL, ogr2ogr -f GeoJSON -lco RFC7946=YES out.geojson in.geojson writes WGS 84, counter-clockwise rings and 7 decimals; -makevalid (GDAL 3.1+) repairs self-intersections.

In Python, shapely’s shape(geometry).is_valid, with explain_validity and make_valid from shapely.validation.

None of them catch swapped coordinates that stay in range: put the data on a map.

FAQ

Questions about validating GeoJSON

Why is my GeoJSON invalid?

Usually a trailing comma, a Feature without properties, coordinates written as strings, a ring that isn’t closed, or latitude before longitude. Paste it above to see which, with the line number.

What is the right-hand rule in GeoJSON?

Outer rings run counter-clockwise, holes clockwise. RFC 7946 says “should”, and d3-geo expects the opposite, so it’s a warning here; the fix reverses the rings that break it.

Does GeoJSON use latitude, longitude or longitude, latitude?

Longitude, then latitude: [2.17, 41.38] is Barcelona. Swapped values often stay in range and pass every check, so check the map.

Should I remove the crs member from GeoJSON?

Yes, once the coordinates are WGS 84 degrees: RFC 7946 removed it in 2016 and most software ignores it. A crs of EPSG:3857 means metres; the validator converts those first.

How many decimals should GeoJSON coordinates have?

Six, about 10 cm, as RFC 7946 suggests. More only makes the file bigger; Round to 6 decimals trims them and shows the bytes saved.

Is my GeoJSON sent anywhere when I validate it?

No. Your browser checks it on your device and never uploads it; only the background map tiles load from the internet. Files up to 50 MB work, and a big one takes a few seconds.

Moving the data into Spatibase? Read how to import a GeoJSON file.

Talk to us

Not sure it’s a fit? Let’s find out

Tell us about your use case and what you need, from data model to security and deployment. In 30 minutes we’ll look at it together and tell you honestly if we can help.

Or write to hello@spatibase.com.