pydantic (original) (raw)

CI Coverage pypi CondaForge downloads versions license Pydantic v2 llms.txt

Data validation using Python type hints.

Fast and extensible, Pydantic plays nicely with your linters/IDE/brain. Define how data should be in pure, canonical Python 3.9+; validate it with Pydantic.

Pydantic Logfire :fire:

We've recently launched Pydantic Logfire to help you monitor your applications.Learn more

Pydantic V1.10 vs. V2

Pydantic V2 is a ground-up rewrite that offers many new features, performance improvements, and some breaking changes compared to Pydantic V1.

If you're using Pydantic V1 you may want to look at thepydantic V1.10 Documentation or,1.10.X-fixes git branch. Pydantic V2 also ships with the latest version of Pydantic V1 built in so that you can incrementally upgrade your code base and projects: from pydantic import v1 as pydantic_v1.

Help

See documentation for more details.

Installation

Install using pip install -U pydantic or conda install pydantic -c conda-forge. For more installation options to make Pydantic even faster, see the Install section in the documentation.

A Simple Example

from datetime import datetime from typing import Optional from pydantic import BaseModel

class User(BaseModel): id: int name: str = 'John Doe' signup_ts: Optional[datetime] = None friends: list[int] = []

external_data = {'id': '123', 'signup_ts': '2017-06-01 12:22', 'friends': [1, '2', b'3']} user = User(**external_data) print(user) #> User id=123 name='John Doe' signup_ts=datetime.datetime(2017, 6, 1, 12, 22) friends=[1, 2, 3] print(user.id) #> 123

Contributing

For guidance on setting up a development environment and how to make a contribution to Pydantic, seeContributing to Pydantic.

Reporting a Security Vulnerability

See our security policy.

Changelog

v2.11.4 (2025-04-29)

GitHub release

What's Changed

Packaging

Changes

Fixes

v2.11.3 (2025-04-08)

GitHub release

What's Changed

Packaging

Fixes

v2.11.2 (2025-04-03)

GitHub release

What's Changed

Fixes

v2.11.1 (2025-03-28)

GitHub release

What's Changed

Fixes

v2.11.0 (2025-03-27)

GitHub release

What's Changed

Pydantic v2.11 is a version strongly focused on build time performance of Pydantic models (and core schema generation in general). See the blog post for more details.

Packaging

New Features

Fixes

New Contributors

v2.11.0b2 (2025-03-17)

GitHub release

What's Changed

Packaging

New Features

Fixes

New Contributors

v2.11.0b1 (2025-03-06)

GitHub release

What's Changed

Packaging

New Features

Changes

Performance

Fixes

New Contributors

v2.11.0a2 (2025-02-10)

GitHub release

What's Changed

Pydantic v2.11 is a version strongly focused on build time performance of Pydantic models (and core schema generation in general). This is another early alpha release, meant to collect early feedback from users having issues with core schema builds.

Packaging

Performance

Fixes

New Contributors

v2.11.0a1 (2025-01-30)

GitHub release

What's Changed

Pydantic v2.11 is a version strongly focused on build time performance of Pydantic models (and core schema generation in general). This is an early alpha release, meant to collect early feedback from users having issues with core schema builds.

Packaging

New Features

Changes

Performance

Fixes

New Contributors

v2.10.6 (2025-01-23)

GitHub release

What's Changed

Fixes

v2.10.5 (2025-01-08)

GitHub release

What's Changed

Fixes

v2.10.4 (2024-12-18)

GitHub release

What's Changed

Packaging

Fixes

New Contributors

v2.10.3 (2024-12-03)

GitHub release

What's Changed

Fixes

v2.10.2 (2024-11-25)

GitHub release

What's Changed

Fixes

v2.10.1 (2024-11-21)

GitHub release

What's Changed

Packaging

Fixes

New Contributors

v2.10.0 (2024-11-20)

The code released in v2.10.0 is practically identical to that of v2.10.0b2.

GitHub release

See the v2.10 release blog post for the highlights!

What's Changed

Packaging

New Features

Changes

Performance

Fixes

New Contributors

v2.10.0b2 (2024-11-13)

Pre-release, see the GitHub release for details.

v2.10.0b1 (2024-11-06)

Pre-release, see the GitHub release for details.

... see here for earlier changes.