
Pydantic is a data validation library that lets Python developers define and enforce data schemas using native type hints.
Key Features:
Whether you're validating scraped data, defining pipeline schemas, or building API models, Pydantic provides robust data integrity with minimal effort.
Web scraping workflow
Pydantic validates and parses Python data according to declared models. It can enforce the shape of extracted records before a scraper writes them into the canonical dataset.
Use it at the boundary between loosely structured HTML extraction and typed application data. Explicit models help expose missing fields or format changes instead of letting malformed values spread through the pipeline.
Pydantic validates the model you define, not the truth of the source. Default parsing can coerce values, so configure strictness when conversion would hide a defect. It does not fetch pages or replace domain checks, and validation failures should remain distinguishable from legitimate empty or unavailable values.
Pydantic is for Python teams that need fast, typed validation for APIs, pipelines, and AI workflows. It is not a scraper or browser automation tool.
Growing a website? Track its keywords, Google rankings, Search Console insights, and share of voice with bisibility. Free during beta.
Our productRepository
pydantic/pydantic
Stars
29.1KForks
3KLast commit
2026-10-15License
MITLanguage
PythonMetrics recorded 2026-10-16
License source: Repository license file
Pydantic validates and serializes data using Python type annotations. You can define models for inputs such as API responses or scraped records and inspect validation errors when values do not match the configured rules. It also generates JSON Schema from those models.
Sources (checked ): Pydantic validation; Pydantic models
Define the expected fields and types in a model, then validate Python values or JSON through the model’s validation methods. By default, Pydantic can coerce compatible input values; strict mode changes that behavior. Invalid inputs raise ValidationError with details about the failing fields.
Sources (checked ): Pydantic validation; Pydantic models
By default, Pydantic models ignore input fields that are not declared in the model. Set the extra configuration to forbid to reject them, or allow to retain them. Choose that policy explicitly for the input contract you need.
Sources (checked ): Pydantic models
Pydantic provides a Python API. In Pydantic v2, its core validation logic is implemented in Rust through pydantic-core. The Python models and the validation engine are different parts of the library.
Sources (checked ): Pydantic validation
Use Field when a type annotation alone does not express the field’s configuration. It can define defaults, aliases, constraints and schema metadata. For a simple required field, an ordinary type annotation may be sufficient.
Sources (checked ): Pydantic fields
Standard Python dataclasses are useful for structured Python objects; they do not enforce annotated types at runtime by themselves. Pydantic models add validation and serialization, and Pydantic also offers a dataclass decorator that validates data. Choose according to the input validation and API behavior you need.
Sources (checked ): Pydantic dataclasses; Python dataclasses
Yes. Pydantic Validation is a library for validating and serializing data. Pydantic AI is an agent framework that uses typed models and supports model providers and tools. They are related projects with different roles.
Sources (checked ): Pydantic validation; Pydantic AI
FastAPI uses Pydantic for data validation and for schema information used in API documentation. Typed request and response models let it check values and describe the API’s data contract.
Sources (checked ): FastAPI features
Verified against the pydantic/pydantic repository and the PyPI package.
Compiled from public repository and package data; check Pydantic's site and repository for current details.