JSON to GraphQL Schema

GraphQL SDL

Generate GraphQL Type Definitions, Queries, and Mutations from any sample JSON payload.

JSON Payload
0 lines · 0 chars JSON
GraphQL Schema (SDL)
Ctrl/Cmd+Shift+C
0 chars GraphQL

About This Tool

Generates a GraphQL SDL type definition from a sample JSON payload, inferring scalars (ID/Int/Float/Boolean/String) field by field, and optionally attaches Query and Mutation type stubs built around that root type's name.

Query/Mutation stubs are schema shape only, not a working resolver or server, pair this with your own backend. For a TypeScript interface or Go struct from the same JSON instead, see JSON to TypeScript or JSON to Go Struct.

Key Features

  • Root Type Name field: names the generated type and feeds the Query/Mutation stub names.
  • Independent Query/Mutation toggles: generate either, both, or neither type.
  • Nullable Fields toggle: switches every field between a strict ! non-null marker and optional.
  • Recursive nested types: each nested JSON object becomes its own named GraphQL type.
  • Download as .graphql: exports the schema to a file named after the root type.

Example

With Root Type Name User and both Query and Mutation types enabled:

{
  "id": "e4a7a8d1-5912-4c22-b5e1-88f192aa0123",
  "username": "alex_rivera",
  "is_admin": true
}

produces:

type User {
  id: ID!
  username: String!
  is_admin: Boolean!
}

type Query {
  getUser(id: ID!): User
  listUsers(limit: Int, offset: Int): [User!]!
}

type Mutation {
  createUser(input: UserInput!): User!
  deleteUser(id: ID!): Boolean!
}

FAQ

How are GraphQL scalar types inferred?
Booleans → Boolean, whole numbers → Int, decimals → Float. Strings that look like a UUID or a field literally named id become ID; every other string is String. Arrays become [InnerType] based on their first element, and nested objects become their own named type (PascalCased from the field name).
What does the Nullable Fields checkbox do?
Unchecked (default), every field gets a GraphQL ! non-null marker. Checking it drops the ! so all fields are optional.
Are the generated Query and Mutation types backed by a real API?
No. They're SDL stubs only, get<Type>, list<Type>s, create<Type>, delete<Type>: meant as a starting point for your own resolvers, not connected to any backend.
What happens if the JSON is invalid?
The output panel shows a # Error: ... comment describing the parse error instead of a schema.
Can I convert GraphQL back to JSON?
No, this tool is one-directional: JSON payload in, GraphQL SDL out. All conversion happens locally in your browser.