Pydantic

Data validation and settings management using Python type hints, backed by a Rust core.

Library
PyPI
v2.14.1
29,161 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
93 /100 Excellent
Development Activity 100
Maintenance 96
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
91 /100 Excellent
Architecture 93
Code Quality 90
Innovation 92
Learning Curve 88

Pydantic is the most widely used data validation library for Python. It lets you define data schemas as ordinary Python classes with type hints, then validates, parses, and serializes data against those schemas at runtime, catching malformed input before it reaches your business logic. Its validation engine is implemented in Rust (pydantic-core) and exposed through a pure-Python API, giving it both speed and Python’s usual ergonomics.

It underpins much of the modern Python web and data ecosystem: FastAPI uses it for request/response validation, SQLModel and various ORMs build on it for typed data access, and it’s a common building block wherever untrusted or external data needs to become trustworthy typed objects — API payloads, config files, CLI arguments, and LLM structured outputs.

What You Get

  • A BaseModel class that validates and parses data purely from Python type-hint annotations
  • A Rust-compiled validation and serialization core (pydantic-core) for near-native performance
  • Automatic JSON Schema generation for every model, ready for OpenAPI docs or LLM structured outputs
  • TypeAdapter for validating arbitrary types (dataclasses, TypedDicts, lists) without a BaseModel
  • Structured, machine-readable validation errors instead of ad hoc exception strings

Common Use Cases

  • Validating and parsing incoming API request/response bodies in FastAPI and similar frameworks
  • Loading and validating application configuration and environment variables via typed settings models
  • Coercing and validating third-party API responses or webhook payloads into typed Python objects
  • Defining structured output schemas for LLM function calling and tool use

Under The Hood

Architecture — Pydantic’s core validation and serialization logic is implemented in Rust in the pydantic-core subproject (pydantic-core/src), compiled to a native extension and exposed to Python via PyO3 bindings. The pure-Python pydantic package (pydantic/main.py’s BaseModel, pydantic/fields.py’s FieldInfo) builds a “core schema” description of each model by walking type annotations in pydantic/_internal/_generate_schema.py, which is then handed to pydantic-core to produce a compiled SchemaValidator/SchemaSerializer pair cached on the model class by pydantic/_internal/_model_construction.py’s ModelMetaclass. At runtime, validation and serialization calls go straight into the compiled Rust validators rather than walking Python-level type trees, which is the mechanism behind Pydantic v2’s speed. Generic models, dataclasses, and TypedDicts route through the same schema-generation path (pydantic/_internal/_generics.py, _dataclasses.py), and JSON Schema derivation (pydantic/json_schema.py) works off the same core schema graph.

Tech Stack — A pure-Python 3.10+ layer with three runtime dependencies (typing-extensions, annotated-types, typing-inspection) plus a version-pinned pydantic-core Rust extension (pydantic-core/Cargo.toml) built with PyO3/maturin-style tooling. Development is uv-managed (uv.lock, pyproject.toml dependency-groups) with pytest, pytest-benchmark and pytest-codspeed for performance-regression tracking, and mypy/pyright cross-checks exercised in tests/.

Code Quality — tests/ contains 170+ test files covering validators, serializers, JSON Schema generation, generics, dataclasses, and the mypy plugin. The project uses pytest-examples to execute every documentation code sample as a real test, pytest-benchmark/pytest-codspeed to guard against performance regressions, and a pre-commit config enforcing lint and format on every change. A dedicated deprecated/ subpackage isolates legacy v1-compatible APIs behind explicit deprecation warnings instead of silently changing behavior, and underscore-prefixed _internal/ modules keep the curated public surface (pydantic/init.py, 456 lines of explicit re-exports) distinct from implementation detail.

API Design — The primary API is a single BaseModel subclass with fields expressed as plain Python type hints, so a working model requires no boilerplate beyond annotations. Validators and serializers are opt-in decorators (functional_validators.py, functional_serializers.py) rather than mandatory ceremony, TypeAdapter provides ad hoc validation for non-BaseModel types, and failures (errors.py) return structured, machine-readable ErrorDetails rather than bare strings — a consistently ergonomic design that libraries like FastAPI and SQLModel build directly on top of.

Used by 116 apps in this directory

Python
100%
GPL 3.0

ComfyUI

AI Design Tools · AI Development

142,410

The most powerful node-based AI workflow engine for creating images, video, 3D models, and audio with full control over every generation step.

View details
92
Repo Health
81
Technical
75
Dependency
Built with
Python 100%
Updated 5 days ago
TypeScript
84%
Apache 2.0

Continue

AI Code Assistants · AI Development · Automation

36,303

Open-source coding agent for VS Code, JetBrains, and CLI with support for 30+ LLM providers.

View details
66
Repo Health
88
Technical
62
Dependency
Built with
TypeScript 84%
Updated 1 weeks ago
Go
33%
Apache 2.0

CubeSandbox

AI Agents · Developer Tools · Security

13,023

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
84
Repo Health
88
Technical
63
Dependency
Built with
Go 33%
Rust 26%
C 22%
Updated 6 days ago
Python
99%
MIT

deepagents

AI Agents · AI Development

30,539

The batteries-included Python agent harness — planning, sub-agents, filesystem, shell, memory, and skills bundled in, built on LangGraph.

View details
88
Repo Health
83
Technical
70
Dependency
Built with
Python 99%
Updated 5 days ago
TypeScript
96%
MIT

deepseek-harness

AI Agents · AI Development · Developer Tools

259,694

An open-source, plugin-based agent harness from DeepSeek AI that runs coding and automation agents across web, desktop, CLI, and SDK surfaces.

View details
82
Repo Health
89
Technical
73
Dependency
Built with
TypeScript 96%
Updated 6 days ago
Python
56%
Other

Dify

AI Development · Design Tools · Developer Tools

159,396

Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.

View details
92
Repo Health
85
Technical
67
Dependency
Built with
Python 56%
TypeScript 42%
Updated 5 days ago
Python
58%
MIT

Docglow

Data Engineering

151

A next-generation documentation site generator for dbt Core projects — lineage explorer, health scoring, and full-text search for teams without access to dbt Cloud's built-in docs features.

View details
69
Repo Health
65
Technical
79
Dependency
Built with
Python 58%
TypeScript 41%
Updated 5 days ago
Python
47%
MIT

Docs

CMS · File Storage

16,942

Open-source collaborative knowledge platform with real-time editing, AI writing tools, and full self-hosting control — built by the French and German governments.

View details
88
Repo Health
81
Technical
68
Dependency
Built with
Python 47%
TypeScript 46%
Updated 6 days ago
Python
53%
Other

Dropbase

AI Assistants · Automation · Developer Tools

1,283

Build internal tools and admin panels faster with AI-generated Python code, fully self-hosted and local-first.

View details
32
Repo Health
58
Technical
80
Dependency
Built with
Python 53%
Shell 29%
Updated 2 years ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers