Loading...
Please wait a moment

MongoDB to GraphQL Converter Online — Convert MongoDB Queries to GraphQL

Paste your MongoDB find() query above and get the equivalent GraphQL query and type definition instantly. This tool converts filter documents to query arguments, projection fields to selections, and chained methods like .sort() and .limit() to GraphQL arguments — all in your browser.

How to Convert MongoDB to GraphQL — Step-by-Step

Step 1

Input Your MongoDB Query

Migrating from MongoDB to a GraphQL API? Paste your find() query from the MongoDB Shell, Compass, or your application code.

Paste: Copy your MongoDB query and paste — conversion is instant
Upload: Select a .js or .json file
Sample: See a find() query with filters, projections, sort, and limit converted
Step 2

Automatic Conversion

The converter maps MongoDB concepts to GraphQL schema concepts:

Collection name: Becomes the root query field
Filter keys: Become query arguments (operators like $gte become named args like age_gte)
Projection fields: Become GraphQL field selections
.sort() / .limit(): Become orderBy and limit arguments
Step 3

Copy or Download

Copy: Paste into your GraphQL server schema or playground
Download: Save as .graphql

Frequently Asked Questions

How does MongoDB map to GraphQL?

MongoDB collection names become root query fields, filter documents become arguments, projection fields become field selections, and chained methods (.sort, .limit) become additional arguments in the GraphQL query.

Does it generate type definitions?

Yes. The converter produces both a GraphQL query and a basic type definition based on the projection fields in your MongoDB query, giving you a starting point for your schema.

Does it handle MongoDB operators?

Yes. Operators like $gte, $lte, $in, and others are converted to descriptive argument names (e.g., age_gte: 21) in the GraphQL query.

Is this converter free?

Completely free, no limits. Also try: GraphQL to MongoDB, SQL to GraphQL, GraphQL to REST, GraphQL Formatter.