GraphQL Schema to TypeScript Types
Convert GraphQL SDL types, enums, and inputs directly into TypeScript interface definitions.
- 100% free
- Private in browser
- No signup
- No watermarks
TypeScript Output (1 types)
export interface Product {
id: string;
title: string;
price: number;
tags?: string[];
}About GraphQL Schema to TypeScript Types
The GraphQL Schema to TypeScript Converter turns GraphQL SDL into exported TypeScript interfaces. Paste type, input, or interface definitions and each block becomes an interface with the same name. Int and Float map to number, Boolean to boolean, ID and String to string, and fields without a ! are marked optional. It reads one field per line and is meant for quick typing of simple schemas: enums become string-literal unions, while unions and custom scalars are left for you to declare.
How to use GraphQL Schema to TypeScript Types
- Paste your type definitions into the GraphQL SDL Schema box.
- Keep each field on its own line, such as price: Float!.
- Check the interfaces and the type count in the TypeScript Output panel.
- Click Copy TypeScript and paste the result into a .ts file.
Key features
- Converts type, input, and interface blocks to export interface
- Maps Int and Float to number, Boolean to boolean, ID and String to string
- Marks nullable fields optional with ? and non-null fields required
- Turns scalar lists such as [String!] into string[]
- Keeps references to other object types by name
- Ignores # comment lines and counts the generated types
Frequently asked questions
- How do I convert a GraphQL schema to TypeScript?
- Paste your SDL into the GraphQL SDL Schema box and the interfaces appear in the TypeScript Output panel. Click Copy TypeScript to copy them into your project.
- How are nullable and non-null fields handled?
- A field ending in ! becomes a required property and every other field becomes optional with ?. For example, title: String! becomes title: string; and tags: [String!] becomes tags?: string[];.
- Are enums, unions, and custom scalars converted?
- Enums are: enum Role { ADMIN USER } on separate lines becomes type Role = 'ADMIN' | 'USER'. Union and scalar definitions are skipped, and a field that uses one keeps that type name, so declare it yourself.
- How are list fields typed?
- Lists of built-in scalars become typed arrays, so [Int] gives number[] and [Boolean] gives boolean[]. A list of object types such as [Review] becomes Review[]. Nested lists are not supported.
- Do fields with arguments work?
- The return type is kept and the arguments are dropped, so posts(first: Int): [Post] becomes posts?: Post[]. The arguments must sit on one line. For full operation typing, run GraphQL Code Generator against your schema.
Related In-Depth Guides
Learn practical workflows, real-world examples, and expert tips in our comprehensive guides:
Password Entropy Explained: How Bits Measure Brute-Force Cracking Time
Understand Shannon entropy in passwords, character pool combinations, and how many seconds, years, or millennia it takes GPUs to crack modern passphrases.
How to Convert Docker Run Commands to Docker Compose YAML Files
A comprehensive developer guide to transforming complex docker run commands into clean, maintainable docker-compose.yml files.
Web Accessibility & Color Contrast (WCAG 2.1): How to Design AA & AAA Palettes
A practical guide to color contrast ratios, accessibility compliance, WCAG 2.1 AA/AAA standards, and building accessible UI palettes.
Rate this tool
Be the first to rate — helps others and improves this page.