JSON to GraphQL Query / Schema
Paste a sample JSON response and get a GraphQL query that selects all its fields, or switch to schema mode for type definitions inferred from the same JSON.
Use the tool
Why this tool exists
When you have a REST payload and want to model it in GraphQL, or you hold a sample response from a GraphQL server and need the query that produced it, writing the nested selection by hand is a chore. The same goes for a first draft of the types.
This tool reads your sample, merges array items to see which fields are optional, and writes either a query or SDL. In schema mode, whole numbers become Int, other numbers Float, and fields that are always present become non-null. It guesses from samples, so inspect the result: an ID field is typed as Int or String, never as ID, and unions and enums need manual work.
How to use it
- Paste a sample JSON response. A top-level data object is unwrapped for you.
- Choose query or schema output, and set the operation or root type name.
- Copy the GraphQL text and refine it by hand.
Frequently asked questions
How are types inferred?
Strings become String, whole numbers Int, other numbers Float and booleans Boolean. A key is non-null only if it appears in every array item and is never null in your sample.
Does it produce ID types, enums or unions?
No. Everything is built from the primitive types, so replace id fields with ID and add enums or unions yourself where the sample cannot tell you.
What names do nested types get?
The field name in PascalCase, made singular. A posts array gives Post, and a clash with an existing name gets a trailing underscore.
Can it handle variables or arguments in queries?
No. The query only lists fields from your sample. Add arguments, variables and fragments by hand so that it matches your real schema and the operation you want to run.