ToolBuddy
In Browser

JSON to Python

Infer Python dataclasses from a JSON sample. Nested objects become named classes with type hints. Keys missing from some objects in an array are optional. Conversion stays in the tab.

Runs in your browser. Nothing is uploaded.

0 characters · 0 lines

0 characters · 0 lines

About this tool

Infer Python dataclasses from a JSON sample. Objects become named classes with type hints. Keys missing from some objects in an array are optional. A JSON null next to a concrete value becomes T | None. Whole numbers stay int. Other numbers become float.

How to use: paste JSON, copy the classes. A root array of objects is Root = list[RootItem]. Empty objects become dict[str, Any] and empty arrays become list[Any]. This is a starting point, not methods, validators, or a Pydantic model.

Example: {"id":1,"name":"Ada","address":{"city":"London"}} yields class Root and class Address. Related: JSON to TypeScript for interfaces, JSON to Go for structs, JSON to Code for JS, Python, or PHP literals.

The sample stays in the tab. Nothing is uploaded. After the page loads, conversion works offline.

FAQ

Related Convert tools