What it does
Pydantic is a Python data-validation library built around type annotations and model classes. A model defines the fields an application expects; methods such as model_validate() check Python objects or JSON input against that definition, and the library can also produce JSON Schema. It is useful at boundaries where a Python service reads configuration, API payloads, or other external data and needs a clear, reusable data shape.
Define a BaseModel for the shape the application expects, then pass incoming data to model_validate(). The official guide shows that models can validate Python objects and JSON, and can be used as a source for JSON Schema. For example, a request model with name: str and age: int makes those fields explicit before the rest of an application uses them. One choice matters at an input boundary: Pydantic attempts type conversion by default, so a value such as a numeric string may become an integer. If the input must already have the declared type, the strict-mode guide explains how to request stricter validation. This distinction helps when validating data from a configuration file or HTTP payload, where permissive conversion may be convenient in one project and undesirable in another. Pydantic is a library used from Python code, not a hosted endpoint that receives data for you. The validation docs site also links to Pydantic AI and Logfire; this entry is for the core validation library and its MIT-licensed repository, not those separate products or their service terms.
Strengths
- Models make expected Python data fields and types explicit.
- model_validate() accepts Python objects, while model_validate_json() supports JSON input.
- The library can generate JSON Schema from model definitions.
Watch out for
- Default validation may coerce compatible input values; strict mode must be selected when conversion is not wanted.
- Models and validation rules have to be defined in Python code and maintained with the application.
Best for
- Python services validating data at API, configuration, or file boundaries.
- Applications that want one typed model to guide validation and schema generation.
- Teams comparing permissive conversion with strict input validation.
Sources
- Pydantic Validation (Oct 25, 2026)
- Installation (Oct 25, 2026)
- Models (Oct 25, 2026)
- JSON Schema (Oct 25, 2026)
- Strict Mode (Oct 25, 2026)
- pydantic/pydantic (Oct 25, 2026)
- MIT License (Oct 25, 2026)
