JSON to GraphQL Schema SDL Generator
Convert JSON to a GraphQL schema online. Maps values to String, Int, Float, Boolean and ID scalars and nests composite types. Free, no upload.
GraphQL type definitions will appear here…
To convert JSON to GraphQL, paste a sample payload on the left. Each value is mapped to a GraphQL scalar — String, Int, Float, Boolean or ID — nested objects become their own types, and the right pane returns SDL type definitions you can drop into a schema file.
GraphQL’s Schema Definition Language describes the types a server exposes. JSON2X infers SDL from a sample payload: values map to the built-in scalars String, Int, Float, Boolean, and ID, nested objects become their own named types, and arrays become list types — giving you a draft schema for data you already have.
How do JSON values map to GraphQL scalars?
Strings become String, booleans Boolean, whole numbers Int, and fractional numbers Float. A field named id becomes ID, the scalar GraphQL reserves for identifiers and serialises as a string. Two limits are worth knowing: GraphQL’s Int is a signed 32-bit integer, so large identifiers and timestamps in milliseconds overflow it and should be ID or a custom scalar. And there is no built-in date type — ISO 8601 strings arrive as String unless you define a DateTime custom scalar.
Why is nullability inverted from what you expect?
In GraphQL every field is nullable by default, and ! marks it non-null — the opposite of TypeScript, where you opt into optionality. Inference therefore starts permissive, which is the safe direction: a nullable field can always be tightened later, whereas removing a ! from a published schema is a breaking change for every client that relied on it. Add ! only where the server genuinely guarantees a value, and remember that a non-null field which errors nullifies its parent.
What does inference not give you?
The parts of a schema that are design decisions rather than shape. There are no Query or Mutation root fields, no arguments or pagination, no interfaces or unions for polymorphic data, no enum types for closed value sets, and no input types for mutation arguments — GraphQL requires separate input types and will not accept an output type there. Inference also cannot see relationships between types, which is where most of the value of a GraphQL schema actually lives.
How to use the JSON to GraphQL
Takes under a minute. Nothing is uploaded — every step runs in this browser tab.
- Paste a sample payload
Put a representative response into the left-hand input pane. An array of records helps the generator judge which fields are always present.
- Name the root type
Set the top-level type name in PascalCase, as GraphQL convention requires.
- Read the SDL
The right-hand pane shows type definitions with scalar fields, nested types declared separately, and list types for arrays.
- Add nullability and queries
Mark guaranteed fields with `!`, then write the Query and Mutation fields that expose these types.
When to use it
- Drafting a GraphQL schema that wraps an existing REST endpoint
- Designing types for a new resolver from a sample response
- Migrating a REST API to GraphQL incrementally, one payload at a time
- Producing SDL to share with a frontend team as a contract
- Sketching types for a mock GraphQL server used in tests
Step-by-step guides for this tool
Task-specific walkthroughs covering the most common ways this tool gets used.
Searches this page answers
- json to graphql online free
- free json to graphql converter
- graphql schema generator online
- graphql schema generator from json
- json to sdl converter
- generate graphql types from json
- graphql type from api response
Frequently Asked Questions
How does JSON to GraphQL conversion work?
The converter creates type declarations with GraphQL scalar types (String, Int, Float, Boolean, ID) and nested composite types.
How are id fields and arrays typed?
Keys named id or _id are mapped to the ID scalar rather than String. An array of objects becomes [Child!] with its own generated type, and an array of primitives becomes a list of the matching scalar.
Can it generate input types and a Query type?
Yes. Both are toggles. The input option emits matching input types for mutations, and the query option adds a Query type with single-record and list fields plus a Mutation type with create, update and delete.
What does the non-null option do?
With it on, fields whose sample value was present are marked non-null with !, while fields that were null stay nullable. Turn it off to emit every field as nullable, which is the safer default for an evolving API.
Is this GraphQL schema generator free, and is my payload uploaded?
It is free with no account, and nothing is uploaded — SDL is generated in your browser from the JSON you paste.
Related Developer Tools
Last reviewed by the JSON2X Engineering Team.