JSON to GraphQL Schema (SDL)

Generate GraphQL SDL object types from JSON: Int vs Float, non-null markers, list types and nested types inferred from your sample. Free and in-browser.

Non-null fields get "!". Integers above 32 bits become Float; mixed or null-only values use a custom JSON scalar.

Runs entirely in your browser. Your data is never uploaded.

Related Tools

View All

What is JSON to GraphQL?

Generate GraphQL schema definition language (SDL) type declarations from a JSON sample. Required values get the non-null marker !, arrays become list types and nested objects become separate object types.

How to use JSON to GraphQL

  1. Paste a JSON sample into JSON input (or click Load sample / Open file).
  2. Set the Root type name (default Root).
  3. Copy the generated GraphQL code or Download it as a file.

Example

Input
{"id":1,"name":"A","tags":["x"]}
Output
type Root {
  id: Int!
  name: String!
  tags: [String!]!
}

When to use JSON to GraphQL

Use it to sketch the schema of a GraphQL API that wraps an existing JSON/REST service. It emits output types only; input types, queries, mutations and resolvers still have to be written.

How JSON to GraphQL works

The sample is walked recursively and every position collects the types it has seen. Arrays of objects are merged into one type: a key missing from some elements becomes optional, a key that is null somewhere becomes nullable, integers mixed with decimals become a floating-point type, and anything else that mixes types falls back to a dynamic type. Nested objects become their own named types (PascalCase of the key, array keys singularized: orders → Order), with numeric suffixes when names collide. GraphQL output maps integers to Int (or Float when a value exceeds 32 bits, since GraphQL Int is 32-bit), decimals to Float, strings to String and booleans to Boolean. Values that are null or missing in the sample are nullable (no !). Mixed or null-only values use a custom JSON scalar, which is declared at the top when needed. Field names that are not valid GraphQL names are converted to camelCase.

Common Use Cases

  • Draft object types for a GraphQL gateway over a REST API
  • Document the shape of JSON data in SDL
  • Start a schema-first API design from sample data
  • Compare REST payloads with an existing GraphQL schema

FAQs

Why is an ID typed Int and not ID?

The sample only shows a number. Change it to ID! if the field is an identifier – the tool cannot know the semantics.

What is the JSON scalar?

A custom scalar used for values whose type varies. Your server must define it, for example with graphql-scalars.

Why Float for big integers?

GraphQL Int is limited to 32-bit signed values; larger numbers would be rejected, so they are mapped to Float (or use a custom BigInt scalar).

Explore more categories