01What is GraphQL to REST?
Sometimes a GraphQL query needs a REST twin. A partner can't use GraphQL, or you are planning a migration, or you just want to show a team how many round trips one query hides. This tool reads a GraphQL query or mutation and suggests what matching REST endpoints could look like. It is a design aid. It knows nothing about your schema and never calls an API. The operation is read by a small tokenizer and parser written for this page, following the GraphQL specification's syntax. Formatting doesn't matter. One-line queries, named operations with variable definitions, aliases, directives such as @include, comments, inline fragments, block strings and nested object or list arguments are all understood. A syntax error, such as a missing closing brace, is reported instead of silently giving you nothing. Named fragment spreads like ...UserFields are skipped, because their fields live in a separate definition. For queries, every field with a selection set becomes a GET endpoint. Arguments named id or slug turn into path parameters, and nested selections become nested paths. Other arguments become URL-encoded query parameters, with variables shown as {name}. Subscriptions are labelled GET (stream). Mutations pick a method from the field name's prefix, loosely following the method meanings in RFC 9110. create, add or insert give POST. update, edit or patch give PATCH. replace gives PUT, and delete or remove give DELETE. The prefix is stripped and the rest becomes the resource, so updatePost(id: 7, title: "New") suggests PATCH /post/:id with the body {"title":"New"}. A single input argument is unwrapped into the body. A name without a known prefix, such as publishPost, falls back to POST /publishPost and the row says the method is a guess. Here is a worked example. user(id: $id) { name posts(first: 5) { title } } produces two rows: GET /user/:id returning name, and GET /user/:id/posts?first=5 returning title. That second row is the extra round trip REST would cost you. Results land in a table of method, endpoint, query parameters or body, and fields, with a copy button per row. Below it you get one cURL command per mapping, pointed at the placeholder host https://api.example.com and quoted safely for the shell. Know the limits. Only the first operation in a document is mapped. Resource names are kept exactly as written, so you will usually want to pluralise them. Everything runs in your browser.
Backend developers and API designers who need to explain, document or plan a REST version of an existing GraphQL operation. The tool runs entirely in your browser, so your data never leaves your device.
02How to use GraphQL to REST
- Paste a query or mutation into GraphQL Query / Mutation, or load an example.
- Click Convert to REST.
- Read any error shown under the button. A syntax problem is described there.
- Review the REST API Mappings table for method, endpoint, params or body, and fields.
- Use the copy icon on a row to copy the method and endpoint line.
- Copy a command from Generated cURL Commands and replace the example host with yours.
03Worked examples
- Input:
query { user(id: 42) { name email } } - Result:
GET /user/:id (fields: name, email) - id and slug arguments become path parameters.
- Input:
query GetUser($id: ID!) { user(id: $id) { name posts(first: 5) { title } } } - Result:
GET /user/:id (fields: name) GET /user/:id/posts?first=5 (fields: title) - Nested selections become nested paths. Other arguments become query parameters.
- Input:
mutation { createUser(input: { name: "John", email: "[email protected]" }) { id name } } - Result:
POST /user with body {"name":"John","email":"[email protected]"} - The create prefix is stripped and a single input argument is unwrapped into the body.
- Input:
mutation { updatePost(id: 7, title: "New") { id title } } - Result:
PATCH /post/:id with body {"title":"New"} - The id moves into the path and only the remaining arguments go in the body.
- Input:
mutation { publishPost(id: 7) { id } } - Result:
POST /publishPost with body {"id":7} (no create/update/delete prefix, so POST is a guess) - Unrecognised names fall back to POST and say so.
- Input:
query { posts(tag: "c++ & js") { title } } - Result:
GET /posts?tag=c%2B%2B%20%26%20js (fields: title) - Query parameter values are URL-encoded.
04Common use cases
- Sketching a REST facade for partners or legacy clients that can't consume your GraphQL API
- Planning a migration from a GraphQL backend to resource-based routes in Express or Spring
- Showing a team how one nested GraphQL selection turns into several REST round trips
- Drafting cURL commands for API documentation from queries the frontend already uses
- Checking that mutation names follow a create/update/delete convention, since unprefixed names get flagged as guesses
- Reviewing a pull request that adds a GraphQL operation and asking what its REST equivalent would cost
05Tips
- Only the first operation in the document is mapped. Split multi-operation files and convert them one at a time.
- Resource names keep the GraphQL spelling, so user becomes /user/:id. REST style usually wants /users/:id, so rename as you go.
- Only arguments literally named id or slug become path parameters. An argument like userId stays in the query string.
- Name mutations with create, update, replace or delete prefixes if you want the method guess to be right.
- Fields without their own selection set show up in the fields column, not as endpoints. Scalars never become routes.
06Related concepts
REST API design, GraphQL, HTTP methods, Path parameters, API migration.
Frequently Asked Questions
What is GraphQL to REST?
GraphQL to REST is a free, browser-based developer tool on AIDToolStack. Convert GraphQL queries to REST endpoints It requires no installation or sign-up and works entirely in your browser.
Is GraphQL to REST free to use?
Yes. No sign-up, no fees and no usage cap.
Does GraphQL to REST store my data?
No. It runs in your browser; nothing is uploaded.