About this tool
The JSON to Pydantic Model tool converts a pasted JSON sample into Python model classes. Python and FastAPI developers constantly scaffold Pydantic models from example API responses, and this converter does it instantly in the browser. It parses your JSON, infers Python types recursively, and emits one class per object: strings become str, ISO date-time strings datetime, date-only strings date, integers int, other numbers float, booleans bool, arrays List[T], and nested objects their own model classes named in PascalCase.
All parsing and generation happen locally with JSON.parse and plain JavaScript, so nothing you paste leaves your machine. Child classes are emitted before the classes that reference them (topological order), and the header only imports what is actually used — BaseModel and Field from pydantic, Optional / List / Union / Any from typing, and datetime / date when relevant. from __future__ import annotations is always included so forward references work regardless of order.
Keys that are missing from some sibling objects, or seen as null, become Optional[T] = None. The output-mode toggle switches between Pydantic v2 BaseModel (default), stdlib @dataclass, and typing.TypedDict. Turn on snake_case fields to rename camelCase or invalid keys and auto-add Field(alias="originalKey") so the model still parses the original JSON. Copy the code or download it as a .py file.