Wrapping an API response
Paste a sample and get dataclasses with type hints, so the response becomes a typed object with autocompletion.
Generate Python dataclasses from a JSON sample in your browser, with type hints.
Maintained by Roshan.
Converts json sample to python dataclass in this tab, with nothing sent anywhere.
Find related browser-local tools for nearby tasks without starting another search.
Browse all generatorsA Python dataclass turns a shapeless dictionary of JSON into a typed object with named fields, and generating one from a sample is the quick way to get there. Paste the JSON, and get a dataclass with type hints already filled in - snake_case field names, the right primitive types, and nested dataclasses for nested objects. This is genuinely useful when you are wrapping an API or loading structured data and want editor autocompletion and a clear shape instead of dictionary key lookups scattered through the code. The inference is conservative: it types what the sample shows, converts keys to Python's snake_case convention, and imports the typing helpers the output needs, so the result runs as written and can be refined from there.
Paste a sample and get dataclasses with type hints, so the response becomes a typed object with autocompletion.
Generate the classes from an example record, then narrow numeric types and mark optional fields.
Yes. Every field is annotated, and the necessary typing imports are included.
Because that is Python's convention. The original key is used to derive it.
float, since JSON has one number type. Change to int where the value is always whole.
Yes. Each becomes its own dataclass referenced by the parent.
Generate TypeScript interfaces from a JSON sample in your browser. Nested objects become their own interfaces.
Generate Go structs from a JSON sample in your browser, complete with json struct tags.
Generate Rust structs from a JSON sample in your browser, deriving Serialize and Deserialize.