JSON to Python
Generate Python TypedDict classes from JSON
Python code
—
Generates TypedDict classes from the JSON shape. Optional[Any] covers null values, List covers arrays, and nested objects become their own class. Types reflect the sample data, so merge unions by hand if fields vary.
About the JSON to Python
The JSON to Python Converter writes TypedDict classes from a JSON sample. It creates nested classes for objects, List types for arrays, and snake_case field names that match Python conventions.
Type hints make API payloads easier to navigate in an editor. Keep the generated classes next to the client that parses the response, and update them when the API changes.
- ✓TypedDict output
- ✓Nested classes
- ✓Snake_case and keyword-safe names
How to use the JSON to Python
- 1
Paste a JSON sample.
- 2
Set the root class name.
- 3
Generate and copy the Python code.
Frequently asked questions
Why TypedDict instead of dataclasses?+
TypedDict describes the shape of plain dictionaries, which is what json.loads returns. Convert to dataclasses if you need methods or runtime validation.
What about fields that are sometimes missing?+
The generator marks null values as Optional[Any]. For keys that disappear entirely, use total=False or a NotRequired annotation.
Save JSON to Python to your favorites, or keep browsing developer tools.
Browse all 35 developer tools →