TS to GraphQL SDL
GraphQL SDL Schema Generator

TypeScript Interface to GraphQL SDL Schema Converter

Convert TypeScript interfaces, type aliases, and enums into standard GraphQL Schema Definition Language (SDL) types, inputs, and scalars.

Presets
TypeScript Interfaces & Types Input
# No TypeScript interfaces, types, or enums detected in source.
# Paste TypeScript definitions or select a scenario preset above.
Defined Types
0 Types & Inputs
Total Fields
0 Fields Generated
Enums & Unions
1.23ms (Pure Client AST)

Client-Side AST Parsing

All TypeScript interfaces, type aliases, and enums are parsed locally in browser memory without sending code to remote servers.

Complete GraphQL SDL Generation

Converts complex TypeScript models into standard GraphQL SDL object types, input types, enums, unions, and custom scalars.

Production Ready & Multi-Tab Export

Export comprehensive schema definitions (.graphql), separate input types, or resolver signatures with instant copy and download.

Technical Reference & Architecture Guide

TypeScript to GraphQL SDL Cheatsheet — Reference Guide

Developer reference for transforming TypeScript interfaces, types, and enums into production GraphQL Schema Definition Language (SDL) schemas.

Key Parameters & Controls

nullabilityMode'ts' | 'strict' | 'nullable'

Governs field nullability semantics. 'ts' reflects optionality (? and null) directly; 'strict' enforces non-null (!) across all fields unless marked optional; 'nullable' strips all non-null modifiers.

Default: 'ts'
autoMapIdboolean

Transforms TypeScript properties named id, _id, or ending with Id from string or number into the native GraphQL ID scalar.

Default: true
smartNumbersboolean

Differentiates TypeScript number types into GraphQL Int or Float based on property naming conventions and contextual AST heuristics.

Default: true
generateInputsboolean

Derives matching GraphQL input object types alongside standard types, omitting read-only IDs and converting sub-types into input variants.

Default: true
parseDeprecationboolean

Detects JSDoc @deprecated tags on TypeScript properties and translates them into GraphQL @deprecated(reason: "...") directives.

Default: true

Pro Tips & Best Practices

Preserve JSDoc Descriptions

Annotate interface properties with multi-line JSDoc comments (`/** ... */`); the generator automatically outputs them as standard GraphQL triple-quote description blocks preceding schema fields.

Convert Enums and Union Types

Define string literal unions (`type Status = 'OPEN' | 'CLOSED'`) to instantly generate clean GraphQL enums instead of polluting your schema with generic String scalar representations.

Isolate Input Object Types

Enable `generateInputs` when building mutations to produce dedicated `input` types that exclude auto-generated database IDs and server-managed timestamps from incoming payloads.

Automate Date Custom Scalars

Configure `declareScalars` to automatically inject `scalar DateTime` into your SDL output whenever TS `Date` or ISO string timestamps are detected across your interfaces.

Common Gotchas & Troubleshooting

Circular TypeScript interface references trigger recursive depth warnings

Break bidirectional references by marking the child relation field as nullable or wrapping cross-references in union types, allowing the generator to emit acyclic SDL references without stack overflow.

Advanced utility types like Omit<T, K> or Pick<T, K> fail to expand field definitions

Expand mapped and utility types into explicit TypeScript interface declarations before conversion, or compile your code via `tsc --declaration` to provide resolved structural AST nodes.

Frequently Asked Questions

Is TypeScript code parsed and converted entirely within the local browser session?▼

Yes. All TypeScript tokenization and AST-to-GraphQL SDL transformations execute client-side using JavaScript AST engines. No source code, types, or schema data are transmitted to external servers.

How does the converter handle TypeScript interface inheritance with extends?▼

Because GraphQL object types do not support direct class-like inheritance, the converter flattens inherited parent interface fields directly into the derived GraphQL type, preserving full field parity.

Can the generator produce GraphQL input types distinct from query object types?▼

Yes. When `generateInputs` is enabled, the tool creates parallel `input` definitions with an `Input` suffix, automatically stripping auto-incrementing ID fields and recursive relation structures.

How are TypeScript string union literals translated into GraphQL specifications?▼

Pure string literal unions (such as `'DRAFT' | 'PUBLISHED' | 'ARCHIVED'`) are translated directly into standard GraphQL `enum` blocks, whereas complex union types are mapped to GraphQL `union` definitions.

Related Tools & Utilities

All Tools →