How to use
- Paste a JSON sample, such as an API response, into the left box.
- Pick a target language and, if you like, a name for the top-level type.
- Click Convert. Nested objects become their own types.
- Copy the code or download it as a source file.
Writing model types by hand for every API response is slow and error-prone. This JSON to types converter reads a sample and generates the matching code: TypeScript interfaces, Swift structs that conform to Codable, Kotlin data classes, Dart classes, Go structs with json tags, Python dataclasses, C# classes and Java classes. Every nested object becomes its own named type, arrays become typed lists, and key names are turned into the naming style of the target language while the original JSON key is kept where the language needs it.
The conversion is done by quicktype-core, the open-source engine behind quicktype (Apache License 2.0), loaded into this page the first time you click Convert. With Types only checked you get plain type declarations. For Swift it keeps the Codable conformance and CodingKeys and drops the convenience initializers. Uncheck it to also get the parsing helpers quicktype normally writes, such as the TypeScript Convert class, Kotlin Jackson annotations or Python from_dict functions.
Types are inferred from the sample, so give it data that shows every field. A null value becomes an optional or any type, numbers without a fraction become integers, and objects that share the same shape in different places can be merged into one type. Your JSON never leaves the browser: parsing and code generation happen on your device and nothing is uploaded or stored.