Skip to content
masterclass Buddy

Pydantic · Module

model_validate_json

Pydantic models describe fields and their types, then validate input against those declarations. They support Python objects, JSON data, and string-valued dictionaries, and they provide methods for serialization and schema inspection.

Last updated

Syntax

class User(BaseModel):
    id: int
    name: str = "John Doe"

User.model_validate(data)
User.model_validate_json(json_data)
User.model_validate_strings(data)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • BaseModel
  • model_validate
  • model_validate_json
  • model_validate_strings
  • model_dump
  • model_dump_json
  • model_fields
  • model_fields_set

Source: Models | Pydantic Docs. Checked 2026-11-03.