ConfigsMay 27, 2026·3 min read

Quicktype — Generate Type-Safe Code from JSON, Schema, and GraphQL

An open-source tool that generates strongly-typed models and serializers for 20+ languages from JSON samples, JSON Schema, TypeScript interfaces, and GraphQL queries.

Agent ready

Review-first install path

This asset needs a review step. The copied prompt tells the agent to dry-run, show the writes, then proceed only after confirmation.

Needs Confirmation · 64/100Policy: confirm
Agent surface
Any MCP/CLI agent
Kind
Skill
Install
Single
Trust
Trust: Established
Entrypoint
Quicktype
Review-first command
npx -y tokrepo@latest install b20dac54-59a5-11f1-9bc6-00163e2b0d79 --target codex

Dry-run first, confirm the writes, then run this command.

Introduction

Quicktype generates strongly-typed data models and serialization code from JSON samples, JSON Schema, TypeScript interfaces, and GraphQL queries. It supports over 20 target languages including TypeScript, Python, Go, Rust, Swift, Kotlin, C#, and Java. The tool eliminates manual type definition work and ensures your code matches the actual shape of API responses and data files.

What Quicktype Does

  • Infers types from JSON samples and produces strongly-typed models in 20+ languages
  • Reads JSON Schema, TypeScript interfaces, and GraphQL queries as input sources
  • Generates marshaling and unmarshaling code for safe JSON serialization
  • Merges multiple JSON samples to infer union types and optional fields
  • Provides a CLI, a Node.js library, and a web playground at app.quicktype.io

Architecture Overview

Quicktype works in three phases. First, an input processor parses JSON samples, JSON Schema, TypeScript, or GraphQL into an intermediate representation (IR) of types. Second, an optimization pass simplifies the IR by merging equivalent types, detecting enums, and resolving union types. Third, a language-specific renderer converts the IR into source code with proper naming conventions, imports, and serialization logic for the target language. Each target language has its own renderer plugin, making the system extensible.

Self-Hosting & Configuration

  • Install globally: npm install -g quicktype
  • Use as a library: npm install quicktype-core for programmatic access
  • Specify input source with -s flag: json, schema, typescript, or graphql
  • Choose target language with -l flag: typescript, python, go, rust, swift, etc.
  • Pipe JSON directly: curl api.example.com/data | quicktype -l python

Key Features

  • Supports 20+ output languages with idiomatic naming and serialization patterns
  • Infers optional fields, enums, and union types from multiple JSON samples
  • Generates runtime validation and conversion helpers alongside type definitions
  • Web playground at app.quicktype.io for quick experimentation without installing anything
  • Extensible architecture allows adding new input formats and target languages

Comparison with Similar Tools

  • json2ts / json-to-ts — TypeScript only; Quicktype supports 20+ languages from the same input
  • OpenAPI Generator — generates client SDKs from OpenAPI specs; Quicktype focuses on raw JSON/Schema to types without needing an API spec
  • Typebox — defines TypeScript types that double as JSON Schema; Quicktype goes the other direction, from data to code
  • datamodel-code-generator — Python-focused code generation from JSON Schema; Quicktype covers many more target languages
  • gRPC / Protobuf — requires defining .proto files upfront; Quicktype infers structure from existing JSON data

FAQ

Q: Can Quicktype handle deeply nested JSON? A: Yes. It recursively infers types for nested objects and arrays, generating corresponding nested classes or structs.

Q: How does it handle fields that are sometimes null? A: It marks those fields as optional (nullable) in the generated types and adds appropriate null-handling in serialization code.

Q: Can I customize the generated code style? A: Yes. CLI flags control naming conventions, access modifiers, and whether to generate helper functions or just types.

Q: Is it accurate with complex JSON? A: Providing multiple JSON samples improves accuracy. Quicktype merges samples to build a comprehensive type that covers all observed variations.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets