JSON to Python
Paste JSON to generate Python classes. Nested objects become their own classes, arrays become typed lists, and keys missing from some records become Optional.
Paste JSON to generate Python classes. Nested objects become their own classes, arrays become typed lists, and keys missing from some records become Optional.
Paste JSON and get ready-to-use Python classes back. Each key becomes a typed attribute, nested objects turn into their own classes, and arrays become List[...] of the right element type. Pick standard library dataclasses for a zero-dependency result, or Pydantic models when you want validation and parsing.
Writing type-hinted classes by hand from an API response is slow, and it's easy to miss an optional field or mistype a nested shape. Drop the JSON here and get correct classes in seconds, then tweak the types instead of starting from a blank file. It's handy when you're wrapping a new API, loading a config file, or seeding test fixtures.
Whole numbers map to int, decimals to float, true/false to bool, and text to str. A field becomes Optional when it's null in any sample or missing from some records in a list, so optional keys stay optional. Required fields are listed before the defaulted Optional ones so the generated class is valid Python. Keys that aren't valid identifiers (like hyphenated names) are folded to underscores.