GraphQL to TypeScript screenshot

GraphQL to TypeScript

Turn a GraphQL schema into TypeScript interfaces: non-null fields become required, nullable fields optional, enums string unions.

Privacy First
0 Runs
Updated 2026-11-17
Runs in your browser
No sign-up, no upload

What the GraphQL to TypeScript does

The schema is tokenized and parsed before anything is emitted, so a list nested inside a non-null is read from the type graph instead of guessed from the text.

Scalars map by name: Int and Float become number, String and ID become string, Boolean becomes boolean. A named type is emitted as itself, which is what makes the interfaces reference each other.

Field arguments are not modelled: the emitted member is the field's return type. This page reads a schema, not a query document.

How to use it

Paste the schema into the GraphQL schema box, or press Run with the example already there.

Read the TypeScript below: every schema type becomes one exported interface, in declaration order.

Check a TypeScript field you expected to be required — a non-null field is emitted without the question mark, and a nullable one carries it.

Worked example

Input:

type Query {
  me: User
}

type User {
  id: ID!
  name: String
}

Output:

export interface Query {
  me?: User | null;
}

export interface User {
  id: string;
  name?: string | null;
}

Why it runs in your browser

The result is produced on this page with JavaScript, so it works offline after the page loads and nothing you enter is sent anywhere.

One exported interface per schema type, emitted in the order the schema declares them, with non-null fields required and nullable fields optional.

An enum becomes a union of its own values, so a misspelled member is a TypeScript error rather than a string.

What it does, and what it does not

The schema is tokenized and parsed before anything is emitted, so a list nested inside a non-null is read from the type graph instead of guessed from the text.

Scalars map by name: Int and Float become number, String and ID become string, Boolean becomes boolean. A named type is emitted as itself, which is what makes the interfaces reference each other.

Field arguments are not modelled: the emitted member is the field's return type. This page reads a schema, not a query document.

How to use GraphQL to TypeScript

Paste the schema into the GraphQL schema box, or press Run with the example already there.

Read the TypeScript below: every schema type becomes one exported interface, in declaration order.

Check a TypeScript field you expected to be required — a non-null field is emitted without the question mark, and a nullable one carries it.

What to Expect

Best for

  • Generating response types from a schema you already own
  • Checking which fields a nullable list makes optional

Not ideal for

  • Typing request variables — argument types are not modelled
  • Reading a query document; this page reads SDL only

What this tool keeps

  • Non-null fields emitted as required
  • Enum values as a string union

What may need cleanup

  • Field arguments need a hand-written type
  • A custom scalar becomes unknown, which you may want to narrow

Common errors

  • The page refuses it: unknown type Missing referenced by Query.me

Example use cases

  • Typing a GraphQL client from its schema
  • Reviewing a schema change as a TypeScript diff

Sample input

GraphQL schema: type Query { …

Sample output

TypeScript: export interface Query { …

Who this is for

  • Frontend developers consuming a GraphQL API
  • Anyone diffing a schema against their own types

Frequently asked questions

Why is a nullable field both optional and nullable?

A field declared String may be absent or explicitly null, so the interface marks it optional and unions it with null. A field declared String! is emitted as a plain required property.

What does a custom scalar become?

unknown, because the schema does not say what the scalar carries. Narrow it by hand where you know the shape — a Date scalar is usually a string.

Does it read extend type?

No. An extension is refused by name so the output cannot silently miss the fields it adds; merge the extension into the base type and re-run.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.