jsontoolskit.org
JSON and JSON Schema utilities, in the browser
Say hi →

JSON → Python

Pydantic v2 · Pydantic dataclass · stdlib dataclass · TypedDict

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

  1. Paste your JSON.
  2. Pick Target: Pydantic v2, Pydantic dataclass, stdlib dataclass, TypedDict.
  3. Configure:
    • Top-level class name (default Root).
    • Use Optional: Optional[X] or X | None.
    • Alias generator (Pydantic) — camelCase from snake_case (or off).
  4. 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.