JSON to Python

Generates Python dataclasses from a JSON sample. Keys become snake_case fields, integers and decimals are told apart as int and float, nested objects become their own dataclasses declared before they are used, and optional keys get a None default. Output targets Python 3.10 or newer. Runs entirely in your browser — nothing is sent to a server.

Ad placeholder: Resp_Horizantal_1 (horizontal)
Ad placeholder: Resp_Square_1 (square)

Generates Python dataclasses from a JSON sample. Keys become snake_case fields, integers and decimals are told apart as int and float, nested objects become their own dataclasses declared before they are used, and optional keys get a None default. Output targets Python 3.10 or newer. Runs entirely in your browser — nothing is sent to a server.

Use cases

  • Turning an API response into typed dataclasses for a client
  • Bootstrapping models from a JSON fixture

Examples

Nested object

{"id":1,"name":"Ada","tags":["math"],"address":{"city":"London"}}
from dataclasses import dataclass


@dataclass
class Address:
    city: str


@dataclass
class Root:
    id: int
    name: str
    tags: list[str]
    address: Address

FAQ

Is my data sent to a server?

No — this tool runs entirely in your browser.

Which Python version does the output target?

Python 3.10 or newer. The output uses builtin generics like list[str] and PEP 604 unions like str | None rather than typing.List and typing.Optional.