Back to Tools

GraphQL to JSON

Convert a GraphQL query shape into a mock JSON response structure.

Input Data

Sketch the JSON a GraphQL query will return

A GraphQL query already describes the shape of its answer: every field you select shows up in the response, nested exactly as written. This tool reads that selection structure and produces a matching mock JSON object, so you can see the expected response layout before the backend exists. It is meant for quick sketching, not for exact data.

Generating the skeleton

  1. Type or paste a query into Input Data. Both the full query form and a bare selection like { user { id name } } are accepted. Sample loads a user with a nested profile.
  2. Click Process / Generate.
  3. Read the JSON structure shown in the result panel. A short status line confirms that a mock structure was generated.
  4. Use Copy or Download to keep it, or Clear to begin another query.

What happens to your query

The leading operation keyword and optional operation name are removed, and the remaining braces are wrapped if needed. A field that opens its own selection set becomes a nested JSON object. A field with no sub-selection becomes a leaf whose value is the placeholder text string. Arguments in parentheses, such as an id filter, are dropped, because they change which record comes back, not the response shape.

Good uses for it

  • Drafting a fixture for a front-end component while the API is still being built.
  • Writing example responses in API documentation or a design proposal.
  • Checking how deep a nested selection goes and whether related fields sit where you expect.
  • Creating a starting point for a mock server or a unit test stub, which you then fill with realistic values.

Know the boundaries

Every leaf gets the same string placeholder, because the tool has no access to your schema and cannot know whether a field is an integer, boolean or list. Replace those values manually. Aliases, variables, fragments, directives and inline fragments are not handled by this simple pattern-based conversion, and lists are not shown as arrays even when the real field returns several items. The result is also shown as a formatted text preview rather than being checked by a JSON validator, so run it through a parser after editing. Wrapping in the standard data envelope that GraphQL servers add to responses is likewise left to you. Treat the output as a scaffold that saves typing the nesting.

Related Tools




Frequently Asked Questions

Does it need my GraphQL schema?
No, and that is why every scalar field receives the same placeholder string. Without a schema the tool cannot tell integers, booleans or arrays from text, so replace the placeholders with realistic sample values afterward.
What happens to query arguments like user(id: 1)?
Arguments inside parentheses are removed from the output. They decide which record the server returns, not the shape of the response, so only the field names and nesting are reflected in the generated JSON.
Can I paste a query with a name, like query getUser { ... }?
Yes. The leading query or mutation keyword and the optional operation name are stripped before conversion. A plain selection wrapped in braces also works, and the tool adds braces if you leave them off.
Will lists come out as JSON arrays?
No. A field that has sub-fields becomes an object even if the real API returns a list of them. If your field is a list, wrap the generated object in an array yourself when you build the fixture.
Is the generated output guaranteed to be valid JSON?
It is a best-effort scaffold produced by text replacement, so complex queries with aliases, fragments or variables can give odd results. Paste the output into a JSON validator after editing, and correct anything the parser complains about.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.