JSON to GraphQL Schema
Generate GraphQL SDL type definitions from a sample JSON response. Infers scalars, nullability, list types and nested object types, and names them from the keys they came from.
Last reviewed by the Radiatus Cloud team
Need this built for your product?
We design, build & host secure software & APIs.
Starting a schema from the API you already have
Most GraphQL layers are put in front of something that already returns JSON: a REST endpoint, a database row, a third party service. The schema work is largely transcription, and transcription by hand is where inconsistencies creep in. One field ends up nullable and its sibling does not, a list of objects gets a singular type name, and an integer that is actually an identifier is typed Int rather than ID.
How types are inferred
Each JSON object becomes a GraphQL type named from the key that contained it, converted to PascalCase and singularised when the key was a plural list. Strings become String, whole numbers become Int, fractional numbers Float and booleans Boolean, with fields named id or ending in Id promoted to the ID scalar. Arrays become list types, and the element type is unified across every element so a list containing both an object with a field and one without it produces a single type where that field is nullable.
Nullability is the interesting decision
GraphQL is null by default and non null is opt in, which is the reverse of most type systems. A field seen as null in the sample is emitted nullable. A field present and non null in every observed occurrence is emitted as non null, marked with an exclamation mark, and flagged in the notes so you can decide whether the sample is really representative. Tightening nullability later is a breaking change for clients, so it is worth reviewing that list rather than accepting it.
Related tools
- JSON Formatter — Format and beautify JSON in your browser. Pinpoints syntax errors by line and column, flags unsafe integers, and never uploads your data to a server.
- JSON Validator — Validate JSON syntax with precise line and column errors, and check documents against a JSON Schema. Runs locally in your browser, nothing uploaded.
- Regex Tester — Test regular expressions against sample text with live match highlighting, capture groups and flag control. Runs entirely in your browser.
- HTML Minifier — Minify HTML by removing comments and redundant whitespace, without breaking inline elements or pre blocks. Runs entirely in your browser.
Frequently Asked Questions
Why did a field come out as non null when it can be null in production?
Because it was never null in your sample. Nullability is inferred, and the tool lists every field it marked non null so you can relax the ones your API can actually omit. Loosening non null later breaks clients, so err toward nullable.
How are type names chosen?
From the key that held the object, converted to PascalCase, with a simple plural to singular rule applied for list fields. An array under a key named "orders" produces a type named Order.
What happens to a field that is null in every record?
It cannot be typed from data, so it is emitted as a nullable String with a comment saying the type is unknown. Replace it once you know the real type.
Does it generate queries or resolvers?
No, only type definitions. A root Query type with a single entry point is included as a starting point, but the field arguments and resolver wiring depend on your data source.
How are mixed type arrays handled?
If elements disagree on a scalar type the list falls back to String with a note. GraphQL unions and interfaces express that properly, but choosing between them is a design decision this tool will not make for you.
Privacy & Security
Everything runs in your browser; nothing is uploaded.
How to Use
Paste a JSON response, set a root type name, and generate the SDL type definitions.
Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.
Related Tools
JSON Formatter
DeveloperFormat and beautify JSON in your browser. Pinpoints syntax errors by line and column, flags unsafe integers, and never uploads your data to a server.
JSON Validator
DeveloperValidate JSON syntax with precise line and column errors, and check documents against a JSON Schema. Runs locally in your browser, nothing uploaded.
Regex Tester
DeveloperTest regular expressions against sample text with live match highlighting, capture groups and flag control. Runs entirely in your browser.