jsontoolskit.org
JSON and JSON Schema utilities, in the browser
Say hi →

JSON to GraphQL

JSON sample → SDL type definitions · updated 28 July 2026

Infer GraphQL schema definition language from a JSON payload. Fields present in every record get the non-null ! marker, optional and nullable ones stay nullable, nested objects become their own types, and you can optionally emit matching input types and a starter Query.

Paste input to start.

How to generate a GraphQL schema from JSON

  1. Paste a JSON sample — ideally an array of several records, so optional fields are detected.
  2. Set the Root type name. Nested objects are named after the key that holds them, singularised for arrays.
  3. Pick the integer scalar. GraphQL's built-in Int is signed 32-bit — if your IDs exceed 2,147,483,647 you need a custom scalar or a String.
  4. Tick input types if clients will send this shape back in a mutation; GraphQL requires separate input types for that.
  5. Copy the code, or download it as a file.

What the non-null markers mean

A field is marked ! only when it was present and non-null in every record you pasted. That makes the sample size significant: two records where one omits email correctly produce a nullable email, whereas a single record marks it required and your schema will lie to clients. Err towards nullable — loosening a field later is a breaking change for clients that relied on non-null.

Field names and keys

By default field names match the JSON keys exactly, so a resolver can return the parsed object untouched. GraphQL convention is camelCase, so tick camelCase field names if you would rather follow that — you will then need resolvers, or a field-name transform, to map back to the underlying keys.

Getting good types out of a sample

Type inference from a sample is only as good as the sample. Three habits make the output far more useful:

Privacy

Nothing is uploaded. Inference and code generation run in this tab. No server sees the payload you paste — which matters, because real API responses tend to contain real user data.

FAQ

Can it infer enums?

No. A repeated string value might be an enum or might be a coincidence in your sample, and guessing wrong bakes a breaking change into your schema. Promote them to enums by hand once you know the full value set.

What is the JSON scalar in my output?

A placeholder for values whose type could not be inferred — a null-only field, or one whose type varies. GraphQL has no built-in JSON scalar, so either define one (graphql-scalars provides it) or replace the field with a concrete type.

Why are lists [String!]! and not [String]?

Because in the sample the list was present and no element was null. [String!]! means "a list that always exists, containing no nulls" — the strongest contract the data supports. Loosen it if your API can return nulls inside the list.