JSON to Types: TypeScript, Swift, Kotlin and More
Paste a JSON sample and get matching type definitions in 8 languages, powered by quicktype.
Runs entirely in your browser. Nothing you enter is sent or stored.
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.
Use cases & tips
Typing an API response
A backend returns {"id":1,"name":"uhub","tags":["dev"],"owner":{"login":"mk"}} and you need models for it. Paste it, choose TypeScript, and you get an interface Root with id: number, tags: string[] and owner: Owner, plus a separate Owner interface. A mobile developer can pick Swift instead and receive a Codable struct with CodingKeys for the same data. For a response with forty fields, this saves a lot of typing and removes typos in key names.
Give it a complete sample
The types describe only what the sample shows. A field that is null in your example becomes any or optional, and an array with a single item hides the other shapes its items can take. Before converting, build a sample in which every field has a real value, and if a number can have decimals, include one that does. The shop order example in the Load example menu shows how nested and optional fields look in the output.
Names, options and languages
The top-level type name defaults to Root, and only letters, digits and underscores are kept. Pick one of 23 languages; the options row changes with it, such as readonly properties or type aliases for TypeScript, a framework for Kotlin, a package name for Go, and a Python version or Pydantic. TypeScript (Zod) and JSON Schema are useful when you also want to validate data at runtime, not only describe it.
Generated code is a starting point
A generator is faster than writing models by hand and more consistent than copying an old file, but it only knows your sample, not the API contract. If the service publishes an OpenAPI or JSON Schema document, that is the better source for optional fields and enums. Treat the output as a first draft: rename types such as Owner if they clash with your own, and check which fields can really be missing.
Frequently asked questions
Is my JSON sent to a server?
No. quicktype-core runs inside your browser. The JSON you paste is not uploaded or saved anywhere.
Why is a field typed as any or optional?
The sample had null there, or the field was missing from some objects. Give a sample with real values to get a concrete type.
Does Swift output use Codable?
Yes. Swift structs conform to Codable and include CodingKeys that map to the original JSON keys.
Can I get Kotlin data classes without a library?
Yes. Keep Types only checked to get plain data classes. Uncheck it to get Jackson annotations and helpers.