GraphQL SDL to TypeScript
Paste a schema and get interfaces, enums, unions and inputs — every mapping rule visible.
GraphQL schema
26 line(s)types.ts
3 interfaces · 1 enums · 1 unions2 types · 1 inputs · 1 enums · 1 scalars
Examples
Nullable fields
type Person { id: ID!, name: String }interface Person { id: string; name: string | null; }GraphQL nullability maps directly to TypeScript unions.
Const enum
enum Role { ADMIN USER }type Role = 'ADMIN' | 'USER'; const RoleEnum = { ADMIN: 'ADMIN', USER: 'USER' } as const;Use the const object for exhaustive lookup tables.
Inputs
input Filter { limit: Int = 10 }interface Filter { limit?: number; }Nullable and defaulted input fields are optional in generated variable types.
About this tool
GraphQL SDL to TypeScript compiles a pasted schema into a types.ts file without a codegen config, package install or build step. Object types and inputs become interfaces, enums become string unions with optional const objects, and unions and interfaces get their own type aliases.
The nullability matrix is handled explicitly: String! becomes string, String becomes string | null, and each of the four list/NonNull combinations gets the matching Array<T> shape. Field arguments are emitted as separate Args interfaces with optional defaults.
Custom scalars are mapped through an editable table (DateTime, JSON, Long, Upload and more), and options add name prefixes, __typename discriminants, exported declarations and @deprecated JSDoc. Parse errors show line and column, while unresolved references are reported instead of hidden.
What this tool does not do
- The parser covers common type-system definitions; exotic directive definitions, schema extension edge cases and executable documents are out of scope.
- Semantic schema validation (interface field compatibility, directive usage, reserved names) is not performed; the emitter reports unresolved type references only.
- The tool does not generate resolvers, operation result types or client hooks; it emits declaration-only TypeScript.
- Names that collide with TypeScript keywords get an underscore suffix, which does not rename any external code that uses the original name.
How to use this tool
Paste SDL
Start with the kitchen-sink example or paste any schema containing types, inputs, enums, unions, interfaces, scalars and schema blocks.
Map scalars
Edit the scalar table to turn custom scalars into string, number, unknown or any TypeScript type your project uses.
Choose options
Add a prefix or suffix to avoid collisions, enable discriminants for tagged unions, or turn off const enum objects and exports.
Review diagnostics
Fix positioned parse errors in the SDL pane and check the unresolved-reference list for types outside the pasted snippet.
Copy types.ts
Copy the generated source or download it directly into your project.
Use cases
Third-party APIs
Paste a vendor's public SDL and get types for a quick integration.
Teaching mapping rules
Show how nullability, lists and enums translate into TypeScript.
Sharing types
Give non-GraphQL consumers a plain types.ts file derived from the schema.
Ad-hoc codegen
Skip a codegen project when you only need types for a small snippet.
SDL to TypeScript mapping
| SDL | TypeScript |
|---|---|
| String! | string |
| String | string | null |
| [String!]! | Array<string> |
| [String]! | Array<string | null> |
| enum Role { ADMIN } | type Role = 'ADMIN'; + RoleEnum |
| field(arg: Int = 5) | interface XFieldArgs { arg?: number } |
| union A = B | C | type A = B | C |
Interfaces implementers extend the base interface; in tagged mode a helper XUnion type narrows polymorphic fields.
Common mistakes
Mistake:Expecting full graphql-js schema validation.
Fix:This is a zero-dependency SDL subset scanner; run graphql-js validation in your build pipeline for semantic checks.
Mistake:Treating unresolved references as generated types.
Fix:Review the unresolved-reference warning and paste the missing definitions or map the scalar.
Mistake:Using a scalar name without adding a mapping.
Fix:Add a row in the scalar table; unmapped scalars fall back to unknown on purpose.
Mistake:Forgetting that nullable input fields are emitted as optional.
Fix:That matches codegen defaults; use ! in SDL when a variable must be present.
Frequently asked questions
Does it need a config file or an npm install?
No. Paste SDL into the left pane and the TypeScript appears on the right. Everything runs in the browser with no build step, so it works for ad-hoc schemas and vendor snippets.
How are custom scalars mapped?
Use the scalar mapping table. Built-ins default to string, number and boolean, and common customs such as DateTime, JSON, Long and Upload have editable rows. An unmapped custom scalar is emitted as unknown and listed as a warning.
How are interfaces and unions emitted?
Implementing object types extend the base interface, and a helper XUnion type lists the implementers. Unions become type aliases; with discriminants enabled each member is intersected with a literal __typename so TypeScript can narrow it.
Are nullable fields handled correctly?
Yes. Non-null fields map to T, nullable fields to T | null, and the four list/NonNull combinations map to Array<T>, Array<T | null> and their nullable forms. Nullable input fields and fields with defaults are optional properties.
Can it generate resolvers types?
Not yet. The tool emits declaration-only types: interfaces, aliases, const enum objects and argument interfaces. Resolver signatures, operation result types and client hooks remain in graphql-codegen territory.
What happens when the schema references a missing type?
Generation continues, the unknown reference is emitted as unknown, and the unresolved-reference warning lists the names. Paste the missing definitions or map the scalar to get a complete result.
Is my schema uploaded anywhere?
No. Parsing and emission happen entirely in your browser tab; no network request is made and the generated code is inert text.
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.gitattributes Generator
Build .gitattributes rules for line endings, Git LFS, GitHub linguist marks and merge drivers — with a one-line explanation for every rule.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
A/B Test Sample Size Calculator
Compute required sample size per variant and test duration from baseline conversion rate, minimum detectable effect, alpha and power.
ABA Routing Number Validator
Validate 9-digit US ABA routing numbers with 3-7-1 Mod-10 breakdown.