JSON to Python Dataclass
Paste JSON and generate clean, ready-to-paste Python dataclasses with nested models, type hints, and optional datetime-aware fields.
Input JSON
Generated Python
Your generated Python dataclasses will appear here.How to use this tool
- Paste a JSON object or array into the input box.
- Set a root class name and choose your preferred dataclass options.
- Enable datetime detection, Optional types, or list default factories if needed.
- Copy the generated Python dataclasses into your project.
Mixed-type arrays and inconsistent sample shapes fall back to
Any when a safe, more specific Python type cannot be inferred.What it handles
- ✅ Nested dataclasses
- ✅ Root arrays and typed lists
- ✅
Optional[...]fields for null or missing values - ✅
datetimedetection for ISO-8601 strings - ✅ Copy-ready browser output
FAQ
Does this tool send my JSON to a server?
No. Everything runs in your browser, so your JSON stays on your device.
What happens to nullable fields?
Nullable or missing fields can be wrapped in Optional[...] and default to None in the generated dataclass.
Does it support root JSON arrays?
Yes. Root arrays generate a typed alias like AutoGenerated = list[AutoGeneratedItem].
Can it generate datetime-aware fields?
Yes. ISO-8601 datetime strings can be inferred as datetime and the tool adds the correct import automatically.