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

  1. Paste a JSON sample, such as an API response, into the left box.
  2. Pick a target language and, if you like, a name for the top-level type.
  3. Click Convert. Nested objects become their own types.
  4. 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.

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.

Related tools