GraphQL Schema to TypeScript MongoDB Converter
Paste a GraphQL SDL schema to generate TypeScript interfaces in the spirit of graphql-codegen-typescript-mongodb, with an approximate _id field added to every generated type. Free online developer tool.
Paste GraphQL Schema (SDL)
TypeScript + MongoDB Interfaces
TypeScript output will appear here...
Free GraphQL Schema to TypeScript MongoDB Converter
Paste a GraphQL SDL schema to generate TypeScript interfaces in the spirit of graphql-codegen-typescript-mongodb, with an approximate _id field added to every generated type.
How to Use It
Paste your GraphQL schema definition language (SDL) into the input box, or click "Load Example" to see a sample run. The tool generates the same TypeScript interfaces as the plain GraphQL to TypeScript converter, then adds an optional _id?: string; field to every generated interface to approximate what Apollo's graphql-codegen-typescript-mongodb plugin would add for types backed by a MongoDB collection.
Example
A User type generates its usual fields (id, name,email, posts) plus an added _id?: string; line and a comment noting that this is an approximation, not an exact reproduction of the real plugin's behavior.
Common Use Cases
- Getting a rough starting point for MongoDB-backed GraphQL resolver types.
- Seeing at a glance how an
_idfield would slot into your existing interfaces. - Quick prototyping before setting up the real graphql-codegen plugin toolchain.
FAQs
Is this an exact match for the real graphql-codegen-typescript-mongodb plugin?
No — this is explicitly a best-effort approximation. The real plugin only adds an _idfield to types you've explicitly mapped to a MongoDB collection (typically typed as ObjectID rather than string), and supports additional configuration this tool doesn't attempt to replicate. This tool adds _id?: string; to every generated interface as a rough, best-effort stand-in — treat it as a starting point, not a drop-in replacement for running the real codegen plugin.
How are custom scalars and nullability handled?
The same as the plain GraphQL to TypeScript converter — custom scalars map to any with a comment, and nullable fields become field?: T | null.
Is my schema uploaded anywhere?
No — parsing and type generation happen entirely client-side in your browser. Nothing you paste is sent to a server.
