Generator Knowledge Base

JSON to GraphQL: Generate Type Definitions & Schema Boilerplate

Generate GraphQL SDL type definitions from any JSON. Produces type, input, Query, and Mutation boilerplate with correct scalars. Free, browser-only.

From JSON to GraphQL API in Seconds

Building a GraphQL API from an existing REST API or database? The hardest part is writing all the type definitions. Paste a sample JSON response and get a complete SDL schema including types, input types, and Query/Mutation boilerplate.

GraphQL Scalar Mapping

  • string → String
  • integer → Int
  • float → Float
  • boolean → Boolean
  • Field named id or _id → ID
  • null → nullable (no ! modifier)

What Gets Generated

  • type TypeName { ... } — Query return type
  • input TypeNameInput { ... } — Mutation argument type
  • type Query { get, list } — Sample query resolvers
  • type Mutation { create, update, delete } — Sample mutations
json
// JSON Input
{ "id": "u1", "name": "Alice", "email": "a@example.com", "age": 28 }

// Generated GraphQL SDL
type User {
  id: ID!
  name: String!
  email: String!
  age: Int!
}

input UserInput {
  id: ID
  name: String
  email: String
  age: Int
}

type Query {
  getUser(id: ID!): User
  listUsers: [User!]!
}

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

Try the free JSON to GraphQL

Runs entirely in your browser — no upload, no signup, and your data never leaves your device.

Open JSON to GraphQL

Frequently Asked Questions

What is a GraphQL input type?

An input type is used as an argument in mutations. Unlike regular types, input types can be passed as arguments and are typically used for create/update operations.

Does the generator support nested objects?

Yes. Nested JSON objects generate separate type and input blocks, referenced by the parent type.

Can I disable the Query and Mutation boilerplate?

Yes. Uncheck "Generate Query boilerplate" in the toolbar to output only the type definitions.

Tools mentioned in this guide

Related JSON Topics & Reference Articles