JSON to Python Dataclass
Turn a JSON object into one Python dataclass. Primitive fields and null values are inferred; nested data stays in Dict/List types.
JSON to Python dataclass
A QUICK WALKTHROUGH
How to use this tool
- Paste one JSON object.
- Generate the dataclass and review inferred annotations.
- Copy the Python code.
Accepted JSON subset
The input must parse as one top-level JSON object. Strings, booleans, integers, decimals, and null values are supported. Null fields become Optional annotations with a default of None.
Nested structures stay simple
Nested objects become Dict[str, Any] and arrays become List[Any]; this tool does not create recursive or multiple dataclasses. Mixed arrays are represented as List[Any].
Safe names and local processing
Keys are sanitized into unique Python identifiers, reserved words receive a trailing underscore, and generated literals are safely represented. Parsing and generation happen in your browser.
GOOD TO KNOW
Common questions
What input is accepted?
One valid top-level JSON object is required.
How are nulls represented?
A null field becomes Optional[Any] = None.
Does it generate nested classes?
No. Nested objects and arrays use Dict[str, Any] and List[Any].