GraphQL Schema to TypeScript Types Generator
Convert GraphQL schema definitions (SDL) into strongly typed TypeScript interfaces and type aliases instantly. Includes support for field arguments, unions, custom scalars, enums, directives, and JSDoc annotations.
Zero Dependencies & Instant
Computes 100% inside your browser using a custom lightweight GraphQL Lexer & AST parser. No heavy bundler compilation or CLI installations required.
100% Client-Side Privacy
Your schema definitions, proprietary models, and business domain objects never leave your browser. Zero server uploads and zero telemetry tracking.
Production-Ready Output
Generates clean TypeScript code that integrates immediately with Apollo Client, GraphQL Code Generator, urql, Relay, or native fetch query wrappers.
GraphQL to TypeScript Type Mapping Rules
| GraphQL SDL Construct | TypeScript Translation | Explanation & Practical Use |
|---|---|---|
| type User { id: ID! } | interface User { id: string; } | Object types become TypeScript interfaces or type aliases with strongly typed properties. |
| String! (Non-Null) | string | Guaranteed to exist. Never null or undefined. |
| String (Nullable) | string | null | undefined | In GraphQL, all unadorned types are nullable by default. |
| [String!]! | string[] | Non-nullable list containing non-nullable strings. |
| [String] | (string | null)[] | null | Nullable list where each element can also be null. |
| union SearchResult = User | Post | type SearchResult = User | Post; | Polymorphic unions map directly to TypeScript union types with discriminated unions. |
| enum Role { ADMIN, USER } | enum Role { ADMIN = 'ADMIN' } | Converted to TS enum, string union ('ADMIN' | 'USER'), or const object per settings. |
| field(limit: Int): [Post] | UserPostsArgs { limit?: number | null } | Field arguments are isolated into strongly-typed parameter interfaces. |
Frequently Asked Questions
Why choose interfaces over type aliases for GraphQL types?
TypeScript interfaces support recursive definitions, declaration merging, and native extension syntax (extends), which closely models GraphQL interface implementations. However, if you prefer pure types, you can toggle the Declaration setting to type.
How are GraphQL custom scalars resolved?
Common scalars like DateTime, JSON, UUID, and Upload are automatically mapped to standard TypeScript equivalents. You can add or modify any custom scalar mapping in the Type Options panel above.
Does this generator support field directives and deprecation?
Yes! Directives such as @deprecated(reason: "...") are recognized and automatically transformed into JSDoc @deprecated comments so VS Code and IDEs display strikethrough notices during development.
Is my schema data private and safe?
Completely. The entire conversion runs locally inside your browser via client-side JavaScript. No API calls or background telemetry are transmitted to any server.