Skip to content
masterclass Buddy

FastAPI · Function

jsonable_encoder

jsonable_encoder converts objects such as Pydantic models and datetimes into ordinary Python data that JSON can encode. It returns a dictionary, list, or scalar values, not a JSON string.

Last updated

Syntax

jsonable_encoder(obj, include=None, exclude=None, by_alias=True, exclude_unset=False, exclude_defaults=False, exclude_none=False, custom_encoder=None, sqlalchemy_safe=True)

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

Subscribe
  • FastAPI
  • Pydantic
  • JSONResponse
  • response_model

Source: Encoders - jsonable_encoder. Checked 2026-11-03.