Use this site to validate and view your GeoJSON. For details about GeoJSON, read the spec.

Programmatic Access

If you need progrmmatic access to validate your GeoJSON you can simply use the same /validate endpoint that this site uses. It's CORS enabled so you can use it from the browser as well as any back end.

POSTing

JavaScript Example via jQuery

POST to the /validate endpoint when you have a JSON blob in memory. If you've got JSON at an accessible URL, see GETing.

var good_geojson = '{"type": "Point", "coordinates": [-100, 80]}';
var bad_geojson = '{"type": "Rhombus", "coordinates": [[1, 2], [3, 4], [5, 6]]}';

function processSuccess(data) {
    if (data.status === 'ok') {
        alert('You just posted some valid GeoJSON!');
    } else if (data.status === 'error') {
        alert('There was a problem with your GeoJSON: ' + data.message);
    }
}

function processError() {
    alert('There was a problem with your ajax.');
}

$.ajax({
    url: 'http://geojsonlint.com/validate',
    type: 'POST',
    data: good_geojson,
    dataType: 'json',
    success: processSuccess,
    error: processError
});

$.ajax({
    url: 'http://geojsonlint.com/validate',
    type: 'POST',
    data: bad_geojson,
    dataType: 'json',
    success: processSuccess,
    error: processError
});

Python Example via Requests

import requests

validate_endpoint = 'http://geojsonlint.com/validate'
good_geojson = '{"type": "Point", "coordinates": [-100, 80]}'
bad_geojson = '{"type": "Rhombus", "coordinates": [[1, 2], [3, 4], [5, 6]]}'

good_request = requests.post(validate_endpoint, data=good_geojson)
bad_request = requests.post(validate_endpoint, data=bad_geojson)

print good_request.json()
# {u'status': u'ok'}
print bad_request.json()
# {u'status': u'error', u'message': u'"Rhombus" is not a valid GeoJSON type.'}

GETing

If you have GeoJSON at a publicly accesible URL, you can utilize the /validate endpoint with a url URL parameter to validate it. The URL must be URL encoded. If you've got JSON in memory POSTing might be a better fit.

import requests

validate_endpoint = 'http://geojsonlint.com/validate'
url = 'http://gitspatial.com/api/v1/JasonSanford/mecklenburg-gis-opendata/parks?lat=35.255&lon=-80.855&distance=1750'

params = {'url': url}

response = requests.get(validate_endpoint, params=params)

print response.json()
# {u'status': u'ok'}

Questions?

Read the blog post or check out the source code.