How to use
- Paste a JSON sample, or click Load sample.
- Set the name of the root model.
- Copy or download the generated code.
Options explained
- Root type name
- Name of the top-level model class. Nested classes are named after their keys.
Examples
{"userName": "ada", "age": 36} becomes:
class Root(BaseModel):
user_name: str = Field(alias="userName")
age: int
Frequently asked questions
Which Python and Pydantic versions does it target?
Pydantic v2 with Python 3.10 or later, using list[str] and str | None annotations.
How do I parse data that uses the original key names?
Fields whose names were changed have an alias, so Root.model_validate(data) accepts the original keys such as userName. To also accept the Python names, set populate_by_name in the model config.
What happens with keys that are Python keywords?
An underscore is added, so a key named class becomes the attribute class_ with alias "class".
Is my JSON uploaded?
No. The types are generated in your browser, so API responses with real data stay on your device.
Privacy
This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.