Skip to content
Latchkey

quicktype: Types from JSON and JSON Schema

quicktype turns JSON samples, JSON Schema, or a GraphQL schema into typed model code (TypeScript, Go, Rust, Python, and more).

quicktype is handy for generating types from real API responses or from JSON Schema. In CI it regenerates committed model files so drift between the schema and the code is caught.

What it does

quicktype reads a source (JSON samples, JSON Schema, or GraphQL) chosen by --src-lang, infers or reads a type model, and emits code in the target --lang. For JSON samples it infers a schema; for JSON Schema it maps types directly.

Common usage

Terminal
quicktype --src-lang schema -l typescript -o Models.ts schema.json
# infer TypeScript from a JSON sample
quicktype api-response.json -o Response.ts
# Go structs from JSON Schema
quicktype --src-lang schema -l go -o models.go schema.json

Options

FlagWhat it does
-s, --src-lang <json|schema|graphql>Input kind (default json)
-l, --lang <name>Target language
-o, --out <file>Output file (extension can imply --lang)
-t, --top-level <name>Name of the root generated type
--just-typesEmit only types, no serialization helpers
--telemetry disableTurn off usage telemetry in CI

In CI

Prefer --src-lang schema over inferring from samples so output is deterministic (sample inference varies with the data). Regenerate into the committed path and git diff --exit-code to fail when the schema changed but the models were not regenerated.

Common errors in CI

"Error: Input is not valid JSON" means a malformed source file. "Error: More than one language specified" means both -l and an output extension disagree. When inferring from samples, missing fields in the sample simply will not appear in the type, so a "wrong" type is usually an incomplete sample, not a tool error; use JSON Schema for stable output.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →