Paste or upload JSON
Add a JSON object or API response to the input panel. Use the sample button to load a realistic user and posts example.
Convert JSON objects and API responses into GraphQL type definitions instantly. Nested objects become separate types, id fields map to the ID scalar, and you can add a Query type with one click, all client-side with no upload needed.
GraphQL schemas are written in SDL, a small declarative language with very few concepts. A type declares a named object with a set of fields. Each field has a name and a type. The leaf types are scalars, which hold actual values rather than further structure.
Generating SDL from a JSON sample maps cleanly: each object becomes a type, each key becomes a field, each nested object becomes another type, and each array becomes a list. The generator's job is choosing scalars and inventing type names.
A blog post payload and the schema it produces.
JSON input
GraphQL SDL
| JSON value | GraphQL scalar | Notes |
|---|---|---|
| Text | String | UTF-8, the default for anything textual |
| Whole number | Int | Signed 32 bit, range roughly plus or minus 2.1 billion |
| Decimal number | Float | Double precision, do not use for currency |
| true or false | Boolean | Direct mapping |
| A key named id or ending in _id | ID | Serialised as a string, signals an identifier |
| Large integer such as a millisecond timestamp | Float or a custom scalar | Exceeds Int range, a BigInt scalar is cleaner |
| ISO date string | String or a custom DateTime scalar | GraphQL has no built-in date type |
| Null only | String, best guess | Nothing to infer from |
| Object | A new type | Named from the key, PascalCased |
| Array | A list type | Element type inferred from the first element |
Int overflowing is a real production issue rather than a theoretical one. A Unix timestamp in milliseconds is about 1.7 trillion, comfortably outside the 32 bit range, and a server will raise a serialisation error when it tries to return it as an Int. Define a custom scalar for large numbers, dates, and money.
This is the concept that trips up everyone arriving from another language. In GraphQL, every field is nullable by default. The exclamation mark marks a field as non-null. It is the opposite of TypeScript, where a field is required unless you mark it optional.
The reason is error handling. If a resolver fails, GraphQL returns null for that field and reports the error alongside the partial data. Marking a field non-null removes that option: the error must propagate upward to the nearest nullable parent, and if there is none, the entire response data becomes null. Non-null is therefore a statement about failure behaviour, not just about data.
| Written as | The list itself | Each item | Reads as |
|---|---|---|---|
| [Comment] | May be null | May be null | Loosest, allows null holes in the list |
| [Comment!] | May be null | Never null | Either no list, or a clean list |
| [Comment]! | Never null | May be null | Always a list, possibly with null entries |
| [Comment!]! | Never null | Never null | Always a list, always clean, usually what you want |
For a collection, [Comment!]! is nearly always the right choice, because an empty list already expresses the absence of results and a null list adds a second empty case for clients to handle.
What comes out of a JSON sample is a set of object types. A working GraphQL API needs considerably more, and none of it can be inferred from data.
Two more things the generator cannot see: a field that appeared once in your sample may be repeatable in reality and should be a list, and circular references between types are normal in GraphQL but impossible to spot in a single flat payload.
Schema definitions pair naturally with other type artefacts. Visit the full converter collection for JSON to TypeScript to type the client side of the same payload, JSON Schema for runtime request validation, and JSON to SQL for the tables your resolvers will read from.
Add a JSON object or API response to the input panel. Use the sample button to load a realistic user and posts example.
Toggle non-nullable fields, the ID scalar for id fields, an optional Query type, and rename the root type.
GraphQL types update live as you type. Copy the output or download a ready-to-use .graphql file.
Bootstrap your GraphQL schema from existing REST API responses or JSON data models in seconds, then extend with resolvers and custom scalars.
Your JSON never leaves the browser. No upload, no server, no logs.
GraphQL types update instantly as you type or change options.
Nested objects each get their own named type in PascalCase with all fields inferred.
Toggle the ! suffix on all fields to match your API's nullability requirements.
Fields named 'id' or ending in 'Id' are automatically mapped to the GraphQL ID scalar.
Export a complete GraphQL schema file ready to use with Apollo or any GraphQL server.
This tool infers GraphQL scalar types from JSON values: strings become String, integers become Int, floats become Float, and booleans become Boolean. Fields named id or ending in Id are mapped to the ID scalar. Nested objects generate separate named types in PascalCase. Arrays of objects produce list fields. All types are output in dependency order so nested types appear before the parent types that reference them. Download the result as a .graphql file to use directly with Apollo Server, GraphQL Yoga, or any schema-first GraphQL framework.