Python classes from a JSON sample
Paste a JSON document and get typed classes for it. The default is a @dataclass per object shape with converter helpers; one checkbox switches to pydantic models, which validate on construction and need no helpers.
Example
With pydantic BaseModel and Classes only checked, targeting Python 3.10:
from pydantic import BaseModel
class Order(BaseModel):
sku: str
qty: int
gift: bool | None = None
class Customer(BaseModel):
id: int
name: str
tags: list[str]
orders: list[Order]
gift is bool | None = None because only some orders in the sample carry it. Nested classes are declared first so forward references are not needed.
Dataclasses
Without pydantic, each class is a @dataclass and the file ends in from_dict/to_dict static methods plus small type-checking functions. The dataclass path has no dependency outside the standard library, which is its reason to exist; pydantic is the choice when the data comes from users or the network and should be validated rather than asserted.
Python version
The Python select changes only the hint syntax. 3.10 is the shortest; 3.9 keeps Optional[] but uses builtin generics; 3.7 is the oldest with dataclasses. Pick the lowest version your runtime supports.
Limits
Inference reads string content. A postal code such as "75001" becomes int unless Integers from numeric strings is turned off under Inference, and pydantic will then reject the real string value. Dates become datetime when date inference is on; mixed-type fields become Union[...] or X | Y.