Skip to main content

GraphQL Schema to TypeScript

Generate TypeScript types from a GraphQL schema: object, input, enum, interface and union types, plus argument types for queries. Private.

More options

GraphQL schema

Stays in your browser

TypeScript

The result appears here after you press Convert.

Shortcuts: Ctrl+Enter run · Ctrl+Shift+C copy result · / search (use ⌘ on Mac)

Free Online GraphQL Schema to TypeScript

Paste a GraphQL schema (SDL) and get TypeScript types for your client or server code. Query and mutation arguments get their own types. It gives developers a quick browser-based way to solve a focused graphql schema to typescript task before moving the result into a project.

How to use GraphQL Schema to TypeScript

Paste your code in the box on the left, or open a file, then press Convert. Nullable fields are optional by default, and enums become string unions. Both can be changed in the options.

Common mistakes

  • Pasting an introspection JSON result instead of SDL: convert it to SDL first.
  • Forgetting that a nullable field may be null at run time: keep the | null in your code.

Frequently asked questions

What are the Args types?
For every field that takes arguments, such as Query.user(id: ID!), a type QueryUserArgs describes the arguments. Use them to type resolver or request code.
How are custom scalars handled?
Common ones (DateTime, JSON, UUID and others) get a sensible type. Unknown scalars become unknown and are listed in a warning so you can replace them.
Can it read a query?
This tool reads schemas (type definitions). A query document is not a schema; the page tells you if you paste one.
Is my code uploaded anywhere?
No. The conversion runs in your browser and nothing you paste is sent to a server.
How do I use this graphql schema to typescript tool?
Use the interactive controls above; processing stays in your browser and the result is intended as a practical starting point for development work.

More Formatters & Parsers

View all Formatters & Parsers tools →