Turn a JSON response into Python dataclasses
Typed API code without hand-writing every field. Paste the response, get @dataclass classes with Optional where the sample needed it.
Tools used in this guide
The job
Python eats JSON fine untyped — until you need autocomplete, a refactor, or a test fixture. Generating the dataclass skeleton from a real response gives you typed fields without transcribing 30 keys by hand.
From sample to classes
Paste the JSON and generate. Objects become @dataclass types named from their keys, lists become list[T] from the merged element type, and fields absent in some objects come out Optional.
- snake_case JSON keys are kept as-is — Python field names mirror the wire keys, so json.loads output drops straight in.
- Mixed-type arrays (1 and "a" together) degrade to Any — fix the sample or accept the wider type.
Check before use
The skeleton is right about structure, not always about type width: an all-integer column may really be float, and a nullable-looking field may just be missing from your sample. Input limit: 2,000,000 characters, depth 40.