Blog / 4 min read

The Complete Guide to GeoJSON: Format, Tools, and Best Practices

Everything you need to know about GeoJSON - the universal format for geographic data. Learn the structure, geometry types, and how to work with GeoJSON effectively.

geojson gis tutorial data-formats
Table of Contents

GeoJSON has become the de facto standard for representing geographic data on the web. It’s human-readable, widely supported, and perfect for web mapping applications.

What is GeoJSON?

GeoJSON is a JSON-based format for encoding geographic data structures. It can represent:

  • Points (locations)
  • Lines (paths, routes)
  • Polygons (areas, boundaries)
  • Collections of these geometries

Basic Structure

Every GeoJSON object has a type property. The most common structure is a FeatureCollection:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [-122.4194, 37.7749]
      },
      "properties": {
        "name": "San Francisco",
        "population": 874961
      }
    }
  ]
}

Geometry Types

Point

A single location:

{
  "type": "Point",
  "coordinates": [-122.4194, 37.7749]
}

Coordinates are [longitude, latitude] (note: longitude comes first!).

LineString

A series of connected points:

{
  "type": "LineString",
  "coordinates": [
    [-122.4194, 37.7749],
    [-118.2437, 34.0522],
    [-117.1611, 32.7157]
  ]
}

Polygon

A closed area with an outer boundary and optional holes:

{
  "type": "Polygon",
  "coordinates": [
    [
      [-122.5, 37.8],
      [-122.3, 37.8],
      [-122.3, 37.7],
      [-122.5, 37.7],
      [-122.5, 37.8]
    ]
  ]
}

The first and last coordinates must be identical to close the polygon.

MultiPoint, MultiLineString, MultiPolygon

Collections of the basic types:

{
  "type": "MultiPolygon",
  "coordinates": [
    [[[...]]],
    [[[...]]]
  ]
}

GeometryCollection

Mixed geometry types:

{
  "type": "GeometryCollection",
  "geometries": [
    { "type": "Point", "coordinates": [0, 0] },
    { "type": "LineString", "coordinates": [[0, 0], [1, 1]] }
  ]
}

Features and Properties

Features wrap geometries and add properties:

{
  "type": "Feature",
  "id": "sf-1",
  "geometry": {
    "type": "Point",
    "coordinates": [-122.4194, 37.7749]
  },
  "properties": {
    "name": "San Francisco",
    "country": "USA",
    "timezone": "America/Los_Angeles",
    "population": 874961,
    "founded": 1776
  }
}

Properties can contain any valid JSON: strings, numbers, booleans, arrays, nested objects.

Coordinate Reference Systems

GeoJSON uses WGS84 (EPSG:4326) by default. Coordinates are:

  • Longitude: -180 to 180
  • Latitude: -90 to 90
  • Altitude (optional): meters above WGS84 ellipsoid
{
  "type": "Point",
  "coordinates": [-122.4194, 37.7749, 100]
}

If your data is in a different CRS, convert it before creating GeoJSON. Our GeoJSON Converter can transform coordinates between systems.

Best Practices

1. Use Consistent Winding Order

For polygons, the outer ring should be counter-clockwise, holes clockwise. This follows the right-hand rule and ensures compatibility.

2. Keep Precision Reasonable

Six decimal places give ~10cm precision—more than enough for most applications:

// Good
[-122.419416, 37.774929]

// Excessive
[-122.41941642761231, 37.77492912847123]

3. Validate Your GeoJSON

Invalid GeoJSON causes silent failures. Common issues:

  • Unclosed polygons
  • Wrong coordinate order
  • Invalid geometry types
  • Missing required properties

Use our GeoJSON Viewer to validate and visualize your data.

4. Include Bounding Boxes for Large Files

Add a bbox property for faster spatial queries:

{
  "type": "FeatureCollection",
  "bbox": [-122.5, 37.7, -122.3, 37.9],
  "features": [...]
}

5. Use Feature IDs

IDs enable efficient updates and lookups:

{
  "type": "Feature",
  "id": "building-123",
  ...
}

Common Operations

OperationDescription
ParseConvert JSON string to object
ValidateCheck structure and geometry validity
TransformConvert to different CRS
SimplifyReduce coordinate count
BufferCreate area around geometries
MergeCombine multiple files

Tools and Libraries

JavaScript

  • Turf.js: Comprehensive geospatial analysis
  • Mapbox GL JS: Web map rendering
  • Leaflet: Lightweight mapping

Python

  • GeoPandas: Pandas for geospatial data
  • Shapely: Geometry operations
  • Fiona: File I/O

Online Tools

GeoJSON vs Other Formats

FormatProsCons
GeoJSONHuman-readable, web-nativeLarge file sizes
ShapefileWidely supportedMultiple files, 2GB limit
GeoPackageSQLite-based, efficientLess web support
KMLGoogle Earth supportXML verbosity
TopoJSONSmaller filesRequires processing

Example: City Points

Here’s a complete example with multiple cities:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [-0.1276, 51.5074]
      },
      "properties": {
        "name": "London",
        "country": "UK",
        "population": 8982000
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [2.3522, 48.8566]
      },
      "properties": {
        "name": "Paris",
        "country": "France",
        "population": 2161000
      }
    }
  ]
}

Try pasting this into our GeoJSON Viewer to see it on a map!

Conclusion

GeoJSON strikes an excellent balance between human readability and machine processability. By following these best practices, you’ll create interoperable geographic data that works across platforms and tools.