JSON to GraphQL
GraphQL schema types (SDL) inferred from a JSON sample.
About this tool
Paste JSON and get GraphQL type definitions. Options use ID for id fields, camelCase field names, add matching input types for mutations, and add a starter Query type.
How the GraphQL is generated
Each JSON object becomes a GraphQL object type and each key a field. Strings map to String, whole numbers to Int, decimals to Float, booleans to Boolean and arrays to lists, while fields named id or ending in _id or Id can use the ID scalar. Fields that are always present and never null are marked non-null with !. Array items are merged before types are chosen, so a key that only some items have, or that is sometimes null, is treated as optional or nullable rather than breaking decoding. Those stay nullable. Values that are always null use a JSON scalar declared at the top, which your server must implement (for example with graphql-scalars). Honest limits: GraphQL's Int is 32-bit, so very large numbers may need Float or ID. If you switch to camelCase names, your resolvers must map them from snake_case keys. The schema describes data shape only, not your queries, mutations or business rules. JSON to TypeScript, the JSON Schema generator and the JSON formatter are related.
Frequently asked questions
How do I create a GraphQL schema from JSON?
Paste a sample response here and copy the generated types into your schema file.
What does ! mean in GraphQL?
Non-null: the field always has a value. Fields that are sometimes missing or null are left nullable.
Why is there a JSON scalar?
For values whose type can't be inferred, such as fields that are always null in the sample.
Is my JSON uploaded?
No. Everything runs in your browser and nothing is stored or sent.