pydantic-geojson
Pydantic validation for GeoJson
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-geojsonuv
uv add pydantic-geojsonpoetry
poetry add pydantic-geojsonInstalling 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
Tags
More GIS packages
Shapely provides Python tools for creating,…
permissive · top 1,000 on PyPI
pyprojpyproj provides a Python interface to PROJ,…
permissive · top 1,000 on PyPI
geopandasGeoPandas extends pandas DataFrames to handle…
permissive · top 1,000 on PyPI
geopygeopy is a Python client for geocoding and…
permissive · top 5,000 on PyPI
pyogrioPyogrio provides fast, bulk-oriented read and…
permissive · top 5,000 on PyPI
h3h3 provides Python bindings to Uber's H3…
permissive · top 5,000 on PyPI
geojsonEncodes, decodes, and represents GeoJSON…
permissive · top 5,000 on PyPI
geojson-pydanticProvides Pydantic models that validate and…
permissive · top 5,000 on PyPI
sigstore-modelsProvides Pydantic-based data models that mirror…
unclear · top 15,000 on PyPI
antimeridianFixes Shapely geometries and GeoJSON features…
permissive · top 15,000 on PyPI
pygeoifPyGeoIf provides lightweight, pure-Python…
copyleft · top 15,000 on PyPI
geometConverts between GeoJSON, WKT/WKB, Extended…
permissive · top 5,000 on PyPI
sigstore-rekor-typesProvides Python data models for Rekor's API…
permissive · top 5,000 on PyPI
openresponses-typesProvides Pydantic models for the OpenResponses…
permissive · top 15,000 on PyPI
stac-pydanticProvides Pydantic models for validating and…
permissive · top 15,000 on PyPI
djangorestframework-gisAdds geographic and GeoJSON support to Django…
permissive · top 15,000 on PyPI