JSON → Python
Paste JSON, pick a Python target. Generates a class definition with typed fields, optional aliases, and choice of Optional[X] or X | None syntax.
Paste JSON.
How to generate Python models
- Paste your JSON.
- Pick Target: Pydantic v2, Pydantic dataclass, stdlib dataclass, TypedDict.
- Configure:
- Top-level class name (default
Root). - Use Optional:
Optional[X]orX | None. - Alias generator (Pydantic) —
camelCasefromsnake_case(or off).
- Top-level class name (default
- Output appears below. Copy or Download as
.py.
FAQ
Which target should I pick?
Pydantic v2 BaseModel for FastAPI / validation-heavy code. stdlib dataclass when you want zero dependencies. TypedDict for typing the shape of a plain dict (no validation).
How are nested objects handled?
Nested objects become dict[str, Any] in this fast inference. For a proper nested class hierarchy, run schema-generator first then schema-to-types.
Will it work offline?
Yes.