Paste Python models written with Pydantic BaseModel, @dataclass or TypedDict, and get back an example JSON document that follows their structure. Field(alias=...) and an alias_generator=to_camel config are read, so you see the keys your snake_case fields really serialize to.
It fits building request examples for FastAPI endpoints, sharing a webhook or queue payload schema with another team, or preparing JSON fixtures for pytest.
.py file holding your models. import lines, methods and decorators such as @field_validator are skipped.Enum classes so those parts are filled in. String forward references ("Order") are understood.Auto, Root type picks the class that isn't used as a field type by another model; you can also choose one from the list.json_schema_extra examples, a test data file or your API docs.class Payer(BaseModel):
model_config = ConfigDict(alias_generator=to_camel)
customer_id: str
email_address: str
class PaymentEvent(BaseModel):
model_config = ConfigDict(alias_generator=to_camel)
event_type: Literal["payment.succeeded", "payment.failed"]
amount: Decimal
currency: str = "KRW"
payer: Payer
receipt_url: Optional[str] = None
retry_count: int = Field(default=0, alias="retries")
raw_payload: dict = Field(exclude=True){
"eventType": "payment.succeeded",
"amount": "0",
"currency": "KRW",
"payer": {
"customerId": "",
"emailAddress": ""
},
"receiptUrl": "",
"retries": 0
}Because of to_camel in model_config, event_type, receipt_url and customer_id turn into camelCase keys, while the explicit alias="retries" wins for retry_count. raw_payload has Field(exclude=True) and is omitted. The Literal takes its first value, payment.succeeded, and the literal default "KRW" is kept as is.
BaseModel (v1 and v2), @dataclass, TypedDict, and Enum/StrEnum/IntEnum including auto().Field(alias=...), serialization_alias, and alias_generator (to_camel, to_pascal) set in model_config = ConfigDict(...) or an inner class Config:._, ClassVar, model_config, and Field(exclude=True) fields.Optional[X] / X | None → sample of X, Literal[...] → first value, Annotated/Required/NotRequired → inner type, list/set/tuple → one-element array, dict[str, V] → {"key": V}.EmailStr, HttpUrl, SecretStr, constr → string; conint, PositiveInt → 0; Decimal and condecimal → the string "0", as Pydantic v2 JSON writes them.datetime → 1970-01-01T00:00:00, date → 1970-01-01, time → 00:00:00, timedelta → PT0S; UUID gets a well-formed value.True/False literal defaults are used as samples; an enum default such as Status.PAID becomes that member's value.Generate JSON from a request model and drop it into model_config = {"json_schema_extra": {"examples": [...]}}; the example on /docs then uses the same alias keys the endpoint expects.
If Celery task or Kafka message payloads are defined in Pydantic, give consumer teams on Node or Go the resulting JSON rather than Python code to agree on the structure.
Create the skeleton of a JSON file for model_validate_json() or API client tests, then change individual values to add edge cases.
Optional fields and fields defaulting to None still get a typed sample instead of null.Decimal is filled as the string "0", matching Pydantic v2 JSON serialization (model_dump_json). If your project emits numbers instead (Pydantic v1, or json.dumps(default=float)), change it to a number.@computed_field, @field_serializer or @model_serializer, is not executed.Union[A, B] uses the first non-None member; discriminated unions selected by a discriminator field are not modeled.default_factory and defaults produced by function calls are not run; the value comes from the type.model_dump_json() prints field names.Pydantic serializes by field name unless you pass by_alias=True. FastAPI's response_model uses by_alias=True by default, which matches this tool's output. When dumping yourself, call model_dump_json(by_alias=True).
Standard dataclass has no renaming, so the field name is the key. If a field carries a trailing # JSON: "orderId" comment, as in dataclasses produced by this site's JSON → Python page, that name is used.
NotRequired keys of a TypedDict included?Yes. The sample is meant to show every possible key, so NotRequired and total=False fields are included. Mark the ones that may be omitted in your docs.
This page is for type-hint based models. For SQLAlchemy models declared with Column(...) or Mapped[...], use the SQLAlchemy → JSON page.