Open Source · TypeScript

Stop writing
types by
hand.

SchemaGen auto-generates TypeScript interfaces from REST APIs, GraphQL schemas, and OpenAPI specs. Accurate, up-to-date types — always.

$ npx schema-gen generate
2k
Weekly Downloads
MIT
License
v3.1
Latest Version
api.json REST
types.ts TS
Input — Raw API Response
1{
2  "user": {
3    "id": 4219,
4    "name": "Alex Chen",
5    "email": "alex@co.io",
6    "role": "admin",
7    "createdAt": "2024-01-15T..."
8  },
9  "permissions": ["read", "write"]
10}
Generated — types.ts
1/** Auto-generated by schema-gen v3.1 */
2
3export type UserRole =
4  | 'admin' | 'editor' | 'viewer';
5
6export interface User {
7  id: number;
8  name: string;
9  email: string;
10  role: UserRole;
11  createdAt: Date;
12}
13
14export interface UserResponse {
15  user: User;
16  permissions: string[];
17}
how it works

Point. Generate. Ship.

01
🎯
Point at your API

Give SchemaGen a REST endpoint, a GraphQL schema URL, or an OpenAPI spec path. Supports remote URLs and local files.

--input https://api.co/openapi.json
02
Generate types

SchemaGen introspects the schema, infers union types, optional fields, and enums, then produces clean TypeScript with JSDoc comments.

npx schema-gen generate
03
🔄
Stay in sync

Run in watch mode or hook into CI. Types regenerate automatically when your schema changes. Diff shows exactly what updated.

schema-gen watch --ci

Works with every
schema format

📄
OpenAPI 3.x

Full spec support including $ref resolution, discriminators, allOf/oneOf/anyOf, and recursive schemas.

Stable
🔷
GraphQL

Introspection query or .graphql SDL files. Generates interfaces for queries, mutations, subscriptions, and fragments.

GQL
🌐
REST Endpoints

Hit a live endpoint, SchemaGen samples the response and infers types. Use sample files for multiple response shapes.

Stable
tRPC Routers

Extract Zod schemas from tRPC routers and generate matching TypeScript interfaces with full runtime validation.

New
🗄️
JSON Schema

Draft 7 and 2020-12 compliant. Handles nested objects, arrays, enums, and conditional schemas.

Stable
🔥
Firebase / Firestore

Point at a Firestore collection and generate typed document interfaces. Rules validation included.

Beta
💎
Prisma Schema

Reads your Prisma schema.prisma and generates full TypeScript interfaces including relations and enums.

TypeScript
📦
Protobuf / gRPC

Proto3 messages and service definitions — generates TypeScript with matching gRPC-web client types.

New
subscribe.ts

Type-safe from
API to component.

schema-gen is free and open source. Subscribe to get release notes, migration guides, and early access to new features delivered straight to your inbox.

Early access to new major releases
Automated migration codemods
Private Discord community server
Priority support on GitHub issues
subscribe.ts — schema-gen
Subscribe to schema-gen updates

No spam · Unsubscribe anytime · MIT forever