skillfed

pydantic-geojson

Pydantic validation for GeoJson

pydantic-geojson v0.3.2 84.1K downloads/30d#14,030 on PyPI39
Permissive license MIT Active released

What it is and what it does

pydantic-geojson wraps the GeoJSON specification (RFC 7946) in Pydantic models, letting you parse and validate geographic data with full type safety. It provides model classes for all nine GeoJSON object types: Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, GeometryCollection, Feature, and FeatureCollection. Each model enforces the correct structure and coordinate ranges automatically.

The library integrates directly with Pydantic's validation pipeline, so you can use it in FastAPI endpoints, define custom property schemas for features, and get automatic OpenAPI documentation. It handles both raw GeoJSON dictionaries (via model construction) and nested geometry validation, making it useful for APIs, geospatial data pipelines, and any application that needs to trust incoming geographic data.

Use it for:

  • Validate incoming GeoJSON in FastAPI endpoints with automatic OpenAPI schema generation.
  • Parse and type-check geographic features from external APIs or file uploads.
  • Define typed property schemas for GeoJSON features to enforce application-specific metadata.
  • Build geospatial REST APIs where coordinate ranges and geometry types must be correct.
  • Store and validate geographic data in applications that work with maps or location services.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides Pydantic-based type-safe validation and models for GeoJSON data according to RFC 7946, supporting all standard geometry types, features, and feature collections.

Yes. The package is actively maintained, has no known vulnerabilities, installs with minimal friction (one dependency), and directly solves the problem of validating GeoJSON data in Python. Use it if you need type-safe GeoJSON handling in any application, especially those using Pydantic or FastAPI.

Install

pydantic-geojson on PyPI

pip

pip install pydantic-geojson

uv

uv add pydantic-geojson

poetry

poetry add pydantic-geojson

Installing pydantic-geojson

Before you install

Low friction: single dependency on pydantic, pure-Python wheel, actively maintained with recent commits and support for current Python versions (3.9 through 3.14).

License in practice

MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.

Quickstart

pip install pydantic_geojson

from pydantic_geojson import PointModel

point = PointModel(
    type="Point",
    coordinates=[-105.01621, 39.57422]
)
print(point)

Requires Python 3.9 or later.

Verify before relying

  • Whether coordinate validation (longitude -180 to 180, latitude -90 to 90) is enforced at parse time or only on explicit validation calls.
  • Performance characteristics when parsing large FeatureCollections or deeply nested GeometryCollections.

Package facts

License MIT (permissive)
Python support supports the current Python release (<4.0,>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 1 — pydantic
Maintenance actively maintained — 166 days since the last release
Last repo commit
First released
Downloads 84,051/month — #14,030 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pydantic_geojson-0.3.2-py3-none-any.whl

Keywords: pydantic, validation, geojson, schema, gis, geo, json, json-schema, rest, fastapi, swagger, openapi

Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Scientific/Engineering :: GIS

Tags

geojson validation pydanticgeojson type modelsrfc 7946 validationgeographic data validationgeojson schema validationpydantic geojson modelscoordinate validationfeature collection models
geospatialgisfastapi-compatible

More GIS packages