JSON to GraphQL Converter
Turn a JSON sample into GraphQL type definitions with required fields marked and lists typed.
How to generate GraphQL types from JSON
Paste your JSON sample
Paste or type it into the box, or press Try an example. Use a real response that has every field you expect.
Name the main type
Set the name of the top-level type, if you want something other than Root.
Check the GraphQL output
Nested objects become their own types. Rename fields or mark optional ones to suit your API.
A field missing from your sample will be missing from the result.
Use it in your project
Paste the types into your schema file.
Worked example
This is what JSON to GraphQL Converter gives for its own sample values. Open the tool above and change anything to try your own.
JSON sample
{
"id": 42,
"user-name": "ada",
"score": 9.5,
"active": true,
"tags": ["admin", "beta"],
"address": { "city": "London", "zip": "N1 9GU" },
"orders": [
{ "sku": "A-1", "qty": 2, "coupon": "SAVE10" },
{ "sku": "B-7", "qty": 1 }
]
}- Name of the main type
- Root
GraphQL types
type Address {
city: String!
zip: String!
}
type Order {
sku: String!
qty: Int!
coupon: String
}
type Root {
id: Int!
userName: String!
...About JSON to GraphQL Converter
Turn a JSON sample into GraphQL type definitions. Fields that always have a value are marked required with !, lists keep their item type, and nested objects become their own types.
FAQs
Which scalar types are used?
String, Int, Float and Boolean.
What about null values?
A field that can be null is left without the ! mark.
Can I get a JSON Schema instead?
Use JSON to JSON Schema Converter.