JSON to GraphQL Schema Converter
Paste JSON and generate GraphQL schema definition language (SDL)
Convert JSON to a GraphQL schema online and generate type definitions in GraphQL SDL from sample data. Paste a JSON object or API response and get GraphQL types with fields and nested objects inferred automatically. This free JSON to GraphQL converter helps developers start building GraphQL APIs faster.
GraphQL schema will appear here.
Press Ctrl+Enter or click Convert.
About JSON to GraphQL Schema Converter
The JSON to GraphQL Schema Converter reads a sample JSON document and produces matching GraphQL type definitions. It is a quick way to start a schema-first API from an existing REST response, a mock payload, or a database export. The conversion runs in your browser, so your data stays on your device.
What Is a GraphQL Schema?
A GraphQL schema is the contract between an API and its clients. Written in schema definition language (SDL), it lists every type the API exposes, the fields on each type, and whether a field is optional, required or a list. Clients use this contract to request exactly the data they need, and servers use it to validate every query before running it. Writing a schema by hand for a large payload is slow and error-prone, so starting from real JSON saves time and keeps the first draft close to the data you already have.
Why Generate a Schema from JSON?
Many projects begin with an existing REST endpoint, a mock response or a database export. Converting that JSON into SDL gives you a working starting point for a GraphQL layer that wraps the same data. It is also useful when documenting an undocumented API, building mock servers for front-end work, or comparing the shape of two payloads. Because the generated types follow the structure of your sample, nested objects and lists are modelled correctly from the first run, and you only need to refine names and nullability.
How Types Are Inferred
- Scalars — strings become
String, whole numbersInt, decimalsFloatand booleansBoolean. - Objects — every nested object becomes its own type, named after its key in PascalCase.
- Arrays — arrays become lists such as
[Project!]!. Array items are merged, so keys missing from some items become nullable. - Nulls and mixed values — null values make a field nullable, and fields holding mixed value types fall back to
String. - IDs — fields named
id,_id,uuidor ending inIdcan be mapped to theIDscalar.
Options
- Non-null fields — adds
!to every field that always has a value in the sample. - Generate input types — adds an
inputtype for every generated type, ready for mutations. - Add Query type — adds a
Querytype with one field that returns the root type.
Real-World Scenarios
- Bootstrapping a GraphQL gateway on top of an existing REST API by converting its sample responses.
- Creating a schema for a mock GraphQL server so front-end work can start before the backend is ready.
- Documenting the shape of a third-party JSON feed as a typed contract.
- Generating input types for mutations that accept the same structure as an existing record.
- Learning SDL by seeing how familiar JSON structures map to GraphQL types.
How to Use
- Paste JSON, upload a file, or fetch it from a URL.
- Set the root type name and choose your options.
- Click Convert or press Ctrl+Enter.
- Copy the schema or download it as a
.graphqlfile.
Things to Review
A schema inferred from one sample can only describe what that sample contains. Check nullability against your
real data, replace generic names where needed, and add custom scalars such as DateTime where a
string holds a date. Key names that are not valid GraphQL names are converted to underscores.
Frequently Asked Questions
Can the root be a JSON array?
Yes. The array items are merged into one type, and the generated Query field returns a list of it.
What happens to empty arrays and null values?
Their type cannot be determined from the sample, so they default to String (or [String]) and stay nullable.
Why is a number shown as Float instead of Int?
If any value for that field has a decimal part, or a whole number larger than the 32-bit integer limit that GraphQL Int allows, the field is typed as Float.
Will the schema work with Apollo, GraphQL Yoga or other servers?
The output is standard SDL, so it can be used with any server or tooling that accepts a schema, including Apollo Server, GraphQL Yoga and code generators. You still need to write the resolvers.
How accurate is the nullability?
It reflects only the sample you provide. A field that is always present in the sample is marked required, so include several representative records, or turn off non-null fields, if your real data is less consistent.
Is my JSON sent to a server?
No. The conversion is done entirely in your browser. Only the optional Fetch button makes a network request, to the URL you enter.