* [ Pydantic Settings  ](../../api/pydantic_settings/)
    * Pydantic Extra Types  Pydantic Extra Types 
      * [ Color  ](../../api/pydantic_extra_types_color/)
      * [ Country  ](../../api/pydantic_extra_types_country/)
      * [ Payment  ](../../api/pydantic_extra_types_payment/)
      * [ Phone Numbers  ](../../api/pydantic_extra_types_phone_numbers/)
      * [ Routing Numbers  ](../../api/pydantic_extra_types_routing_numbers/)
      * [ Coordinate  ](../../api/pydantic_extra_types_coordinate/)
      * [ Mac Address  ](../../api/pydantic_extra_types_mac_address/)
      * [ ISBN  ](../../api/pydantic_extra_types_isbn/)
      * [ Pendulum  ](../../api/pydantic_extra_types_pendulum_dt/)
      * [ Currency  ](../../api/pydantic_extra_types_currency_code/)
      * [ Language  ](../../api/pydantic_extra_types_language_code/)
  * Examples  Examples 
    * [ Secrets  ](../../examples/secrets/)
  * Error Messages  Error Messages 
    * [ Error Handling  ](../../errors/errors/)
    * [ Validation Errors  ](../../errors/validation_errors/)
    * [ Usage Errors  ](../../errors/usage_errors/)
  * Integrations  Integrations 
    * [ Mypy  ](../../integrations/mypy/)
    * [ PyCharm  ](../../integrations/pycharm/)
    * [ Hypothesis  ](../../integrations/hypothesis/)
    * [ Visual Studio Code  ](../../integrations/visual_studio_code/)
    * [ datamodel-code-generator  ](../../integrations/datamodel_code_generator/)
    * [ devtools  ](../../integrations/devtools/)
    * [ Rich  ](../../integrations/rich/)
    * [ Linting  ](../../integrations/linting/)
  * [ Blog  ](https://blog.pydantic.dev/)
  * [ Pydantic People  ](../../pydantic_people/)

Page contents

  * Generating JSON Schema 
    * Configuring the JsonSchemaMode 
  * Customizing JSON Schema 
    * Field-Level Customization 
      * Unenforced Field constraints 
    * Model-Level Customization 
    * Using json_schema_extra 
      * Using json_schema_extra with a dict 
      * Using json_schema_extra with a Callable 
    * WithJsonSchema annotation 
    * SkipJsonSchema annotation 
    * Implementing __get_pydantic_core_schema__ 
    * Implementing __get_pydantic_json_schema__ 
  * JSON schema types 
  * Top-level schema generation 
  * Customizing the JSON Schema Generation Process 
  * Customizing the $refs in JSON Schema 
  * Miscellaneous Notes on JSON Schema Generation 

#  JSON Schema

API Documentation

[ ` pydantic.json_schema ` ](../../api/json_schema/#pydantic.json_schema)  

Pydantic allows automatic creation and customization of JSON schemas from
models. The generated JSON schemas are compliant with the following
specifications:

  * [ JSON Schema Draft 2020-12 ](https://json-schema.org/draft/2020-12/release-notes.html)
  * [ OpenAPI Specification v3.1.0 ](https://github.com/OAI/OpenAPI-Specification) . 

##  Generating JSON Schema  ¶

Use the following functions to generate JSON schema:

  * [ ` BaseModel.model_json_schema ` ](../../api/base_model/#pydantic.BaseModel.model_json_schema) returns a jsonable dict of a model's schema. 
  * [ ` TypeAdapter.json_schema ` ](../../api/type_adapter/#pydantic.type_adapter.TypeAdapter.json_schema) returns a jsonable dict of an adapted type's schema. 

Note

These methods are not to be confused with [ ` BaseModel.model_dump_json `
](../../api/base_model/#pydantic.BaseModel.model_dump_json) and [ `
TypeAdapter.dump_json `
](../../api/type_adapter/#pydantic.type_adapter.TypeAdapter.dump_json) , which
serialize instances of the model or adapted type, respectively. These methods
return JSON strings. In comparison, [ ` BaseModel.model_json_schema `
](../../api/base_model/#pydantic.BaseModel.model_json_schema) and [ `
TypeAdapter.json_schema `
](../../api/type_adapter/#pydantic.type_adapter.TypeAdapter.json_schema)
return a jsonable dict representing the JSON schema of the model or adapted
type, respectively.

on the "jsonable" nature of JSON schema

Regarding the "jsonable" nature of the [ ` model_json_schema `
](../../api/bas