{ JSON to GraphQL Type }

// turn json objects into graphql type definitions

Convert JSON objects into GraphQL type definitions instantly. Auto-detects scalar types (String, Int, Float, Boolean, ID) and generates clean, ready-to-use GraphQL schema types.

Paste your JSON object or array
{ }

Ready to generate

Paste JSON and click Generate

HOW TO USE

  1. 01
    Paste Your JSON

    Enter any valid JSON object or array into the input field on the left.

  2. 02
    Set Type Name

    Enter a meaningful name for your root GraphQL type (e.g. User, Product).

  3. 03
    Generate & Copy

    Click Generate and copy the ready-to-use GraphQL type definitions.

FEATURES

Auto scalar detection Nested objects Array support ID detection Non-null (!) toggle Multi-type output

USE CASES

  • 🔧 Bootstrap a GraphQL schema from an existing REST API response
  • 🔧 Generate types for Apollo, Hasura, or Prisma projects
  • 🔧 Prototype GraphQL schemas quickly from sample data
  • 🔧 Convert Postman/Insomnia response payloads to schema types

WHAT IS THIS?

This tool parses your JSON structure and generates valid GraphQL SDL (Schema Definition Language) type definitions. It automatically maps JSON value types to GraphQL scalars: numbers become Int or Float, booleans become Boolean, UUID-like strings become ID, and everything else becomes String. Nested objects produce additional named types.

RELATED TOOLS

FREQUENTLY ASKED QUESTIONS

What scalars does this tool detect?

The tool maps JSON types to GraphQL scalars: true/falseBoolean, integer numbers → Int, decimal numbers → Float, UUID-formatted strings → ID, and all other strings → String. Null values default to String.

How are nested objects handled?

Nested JSON objects generate separate named GraphQL types. The sub-type name is created by combining the parent type name with the field name in PascalCase. For example, a address field inside User generates a UserAddress type.

What does the Required (!) toggle do?

When enabled, all fields are marked as non-null with the ! suffix (e.g. name: String!). This matches the common convention of defining schema fields as required by default and handling nullability explicitly. Toggle it off to leave fields nullable.

Can I use this with Apollo Server or Hasura?

Yes. The generated output is standard GraphQL SDL compatible with any GraphQL server: Apollo Server, GraphQL Yoga, Hasura remote schemas, Pothos, Nexus, and more. You may need to add resolvers or adjust field names to match your data source.

What if my JSON has arrays?

Array fields are wrapped in GraphQL list notation: [String], [Int], etc. Arrays of objects generate a sub-type and produce [SubType] fields. Only the first element of each array is used to infer the item type.

Does this tool send my JSON to a server?

The conversion is performed server-side via a lightweight PHP API on the same domain. No data is stored, logged, or shared. For sensitive payloads, you can anonymize values before pasting — only the JSON structure and types matter for schema generation.

JSON to GraphQL Type Generator — Free Online Tool

Manually writing GraphQL type definitions from a JSON payload is tedious and error-prone. This free tool automates the process: paste any JSON object, click generate, and get clean GraphQL SDL type definitions ready to drop into your schema file.

💡 Looking for premium JavaScript plugins and scripts? MonsterONE offers unlimited downloads of templates, UI kits, and developer assets — worth checking out.

What Is GraphQL SDL?

GraphQL SDL (Schema Definition Language) is the human-readable syntax used to define types, queries, mutations, and subscriptions in a GraphQL API. A type definition describes the shape of data: its fields and their types. For example:

type User {
  id: ID!
  name: String!
  age: Int!
  email: String!
}

Every field has a name and a type. The exclamation mark (!) means the field is non-null — it will always have a value. SDL is used by tools like Apollo Server, GraphQL Yoga, Hasura, Nexus, and Pothos to build type-safe APIs.

How JSON Maps to GraphQL Scalars

GraphQL has five built-in scalar types, and JSON value types map to them naturally:

This tool performs that mapping automatically. Rather than reading every field and guessing the type, the tool inspects the actual value in your sample JSON and assigns the most precise GraphQL scalar.

Handling Nested Objects and Arrays

Real-world APIs rarely return flat objects. Nested structures are common — a User might have an address object, a list of roles, or embedded metadata. This tool handles all of these:

Non-Null vs Nullable Fields

In GraphQL, fields are nullable by default — they can return null. Adding ! makes a field non-null. Most schema designs use non-null as the default and add nullability only where needed. The "Required (!)" toggle in this tool lets you choose your preferred convention. Enable it to generate field: Type! everywhere; disable it for the nullable default field: Type.

From REST to GraphQL — A Common Use Case

Teams migrating from REST to GraphQL often have existing API responses documented or captured in Postman or Insomnia. Instead of manually transcribing every field into SDL, you can paste the response JSON here and get a complete starting schema in seconds. It's a practical way to bootstrap a GraphQL API layer over an existing data source.

PascalCase Type Names

GraphQL convention is to use PascalCase for type names (UserProfile, not user_profile). This tool automatically converts the type name you provide and any derived sub-type names into PascalCase. Field names retain their original casing but special characters are replaced with underscores to keep them valid GraphQL identifiers.

Tips for Better Schema Generation