--- id: pydantic-geojson version: "0.3.2" license: MIT license_treatment: permissive maintenance: active --- # pydantic-geojson — Pydantic validation for GeoJson License: permissive · Maintenance: active · Downloads: 84.1K/mo ## 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 above — 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 pip install pydantic-geojson uv add pydantic-geojson 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_current - Install friction: low - Maintenance: active - Downloads: 84.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags geojson validation pydantic, geojson type models, rfc 7946 validation, geographic data validation, geojson schema validation, pydantic geojson models, coordinate validation, feature collection models, geospatial, gis, fastapi-compatible [View on SkillFed](https://skillfed.io/packages/pydantic-geojson) · [View on PyPI](https://pypi.org/project/pydantic-geojson/)