Paste any JSON and get ready-to-use Python types in one click. Nested objects, arrays, optional fields and awkward key names are handled for you, and everything runs in your browser, so API responses and sample payloads are never uploaded.
Root.JSON input
{
"id": 1,
"name": "Alice",
"active": true,
"score": 98.5,
"tags": ["admin"],
"address": { "city": "New York" }
}Python output
from __future__ import annotations
from dataclasses import dataclass
from typing import List
@dataclass
class Root:
id: int
name: str
active: bool
score: float
tags: List[str]
address: Address
@dataclass
class Address:
city: str| JSON | Python |
|---|---|
| string | str |
| whole number | int |
| decimal number | float |
| boolean | bool |
| array | List[T] |
| object | a @dataclass |
| null / unknown | Any |
Field names keep the original key when it is a valid Python identifier; otherwise they become snake_case with a comment showing the original key. Required fields are listed first, because dataclass fields with defaults must come last.
import json
root = Root(**json.loads(text)) # flat objects
# nested data: use dacite or pydantic to build the nested dataclassesDescribe the same data with the JSON Schema generator, get TypeScript interfaces, create a SQL table, fix broken input with JSON Repair, or compare payloads with JSON Diff.
Paste your JSON and copy the generated code. Objects become @dataclass classes, arrays become List[T], and fields that are null or missing in some items become Optional[T] = None.
Python dataclasses require fields without defaults to come before fields with defaults, so the generator sorts required fields first and puts Optional fields (default None) last.
For flat objects use Root(**json.loads(text)). For nested data, use a library such as dacite or pydantic to build the nested dataclasses from a dict. Keys that are not valid Python identifiers are renamed to snake_case with a comment showing the original key. Everything runs in your browser — your JSON is never uploaded to a server.