Python reference

Pydantic & core
cheat sheet.

Pydantic models, validation, serialization, settings, and custom types, with direct pydantic-core examples.

44 topics60 code examplesUpdated
How Pydantic & core fits together
01Describe the shapePython types and field rules define accepted input.
02Validate the boundaryPydantic builds and runs a compiled core schema.
03Use typed valuesYour application works with checked Python objects.
04Control the outputSerialization defines the public data you expose.
Jump to a specific topic

Choose a chapter

5 chapters · 44 topics

CHAPTER 01 / 05

Models, fields, and types

Define Pydantic models with typed fields, defaults, aliases, nested data, and discriminated unions. Handle strict input and partial updates.

12 topics
CHAPTER 02 / 05

Validation and serialization

Write Pydantic field and model validators, custom serializers, and computed fields. Handle validation errors and keep sensitive fields out of output.

9 topics
CHAPTER 05 / 05

Custom types and core schemas

Build Pydantic custom types and pydantic-core schemas. Python examples cover SchemaValidator, SchemaSerializer, context, unions, and tests.

13 topics