Pydantic, by Running It

Type annotations that actually do something. Validation, coercion and serialisation, each one runnable on the page.

30 modules Free, no login Updated 31 August 2026

About this track

A Python type annotation does nothing at runtime. Write <code>def price(x: int)</code> and Python will hand your function the string "cat" without a word of complaint. Pydantic is the library that makes those annotations real - it reads them, checks the data against them, and tells you precisely what was wrong when it does not fit.

This track works up from a first model to validators, serialisation and schemas. Every idea arrives as a small program you can run and edit on the page, because the fastest way to settle what Pydantic does with a value is to hand it one and look.

Every model on these pages runs in the browser against Pydantic itself, including the ones written to fail - because the error a library gives you is part of learning it, and reading one is a skill the documentation cannot teach.

What you will be able to do

How the track is ordered

Models and fields come first, then validation - what happens automatically, what you have to ask for, and how to read the error when it fails. Types follow: nested models, optionals, enums, dates, decimals and the custom types that the standard library does not cover. Then the parts that shape a real application - settings, aliases, serialisation, generics and the FastAPI integration - and finally performance and the v1-to-v2 migration you will meet in existing code.

Where this leads

Pydantic is the validation layer under FastAPI, so the FastAPI track assumes what is here. It is also the boundary layer for anything that reads JSON, environment variables or a config file.

All 30 modules, in teaching order

  1. 01What Pydantic Is For
  2. 02Your First BaseModel
  3. 03Types and Coercion
  4. 04Required, Optional and Defaults
  5. 05Reading a ValidationError
  6. 06Field Constraints
  7. 07Pydantic vs Dataclasses
  8. 08Nested Models
  9. 09Collections of Models
  10. 10Unions and Discriminated Unions
  11. 11Enums and Literals
  12. 12Dates, UUIDs and Decimals
  13. 13Strict vs Lax Mode
  14. 14field_validator
  15. 15model_validator
  16. 16Computed Fields
  17. 17model_config
  18. 18Annotated and Custom Types
  19. 19Validator Modes
  20. 20model_dump and model_dump_json
  21. 21Aliases
  22. 22Parsing JSON
  23. 23Custom Serializers
  24. 24JSON Schema
  25. 25TypeAdapter
  26. 26Generic Models
  27. 27Settings Management
  28. 28Pydantic with FastAPI
  29. 29Performance and pydantic-core
  30. 30Migrating v1 to v2

Other tracks