JSON to Pydantic Model Converter
NewConvert a JSON sample into Pydantic v2 BaseModel classes with nested models, Optional fields, lists and snake_case aliases.
json to pydanticpydantic model generatorjson to python classfastapi model
Read the guideShortcuts:⌘ KSearch?HelpD MDark modeG TAll tools
Continue with:
Frequently Asked Questions
Which Pydantic version does it target?
Pydantic v2 BaseModel syntax, with an option for Python 3.9 style Optional and List typing.
How are nested objects handled?
Each nested object becomes its own class, defined before the class that uses it.
How are keys that aren't valid Python names handled?
They are converted to snake_case and given a Field alias with the original key.
How does it infer optional fields?
Keys that are null or missing in some array items become optional with a None default.