GraphQL Schema Tools

Generate & Validate
GraphQL Schemas

Convert JSON to GraphQL type definitions and validate your API structures. Perfect for GraphQL server development and schema-first API design.

Open GraphQL Schema Generator

GraphQL SDL in four steps

Paste your JSON data Drop any valid JSON object or array into the input panel.
Select GraphQL output Switch to the Convert tab and choose the GraphQL option.
Copy SDL type definitions One-click copy puts the generated GraphQL SDL on your clipboard.
Add to your GraphQL server Paste into Apollo Server, GraphQL.js, or Hasura and start building immediately.

No account. No upload. No nonsense.

🔒

No Server

Your JSON never leaves your device. There is no backend to send it to.

SDL Compatible

Generated SDL works with Apollo Server, GraphQL.js, Hasura, and all major GraphQL tools.

📡

Works Offline

Load once and use forever — even on a plane or without internet access.

Related JSON tools

JSON to GraphQL Generate GraphQL SDL type definitions from any JSON structure instantly.
JSON to OpenAPI Generate OpenAPI schema definitions from a sample JSON response.
JSON Schema Validator Validate JSON against a Draft-07 schema with detailed error messages.
JSON Formatter Pretty-print JSON with syntax highlighting and a collapsible tree view.

Common questions answered

How do I generate a GraphQL schema from JSON?

Paste your JSON in the Convert tab and select the GraphQL option to generate SDL type definitions instantly.

What GraphQL types are supported?

The generator produces String, Int, Float, Boolean, and custom object types. Arrays become list types ([Type]).

Does my data leave my browser?

No. All processing is 100% client-side.

Can I use the output with Apollo Server?

Yes. The generated SDL is compatible with Apollo Server, GraphQL.js, Hasura, and other GraphQL implementations.

What is GraphQL Schema Definition Language (SDL)?

SDL is the human-readable text format used to define GraphQL schemas. It specifies types, fields, and their relationships — the backbone of any GraphQL API.

What is GraphQL schema validation?

GraphQL schemas define the types, queries, mutations, and subscriptions available in a GraphQL API. Schema validation checks that your SDL (Schema Definition Language) is syntactically correct and internally consistent — all referenced types exist, field types resolve properly, and directives are applied correctly. Catching errors before deployment prevents runtime failures in production.

This tool validates GraphQL schema definitions by parsing the SDL syntax and checking for common errors like missing type definitions, duplicate field names, and invalid directive usage. Paste your schema SDL to get instant feedback with line-level error reporting. This is particularly useful when editing schemas by hand or merging fragments from multiple services in a federated architecture.

Validate a GraphQL schema
Input
type User {
  id: ID!
  name: String!
  email: String
  posts: [Post!]!
}

type Post {
  id: ID!
  title: String!
  author: User!
}
Output
✓ Valid GraphQL Schema
  Types: User, Post
  Fields: 7 total
  Relations: User → Post
    (1-to-many)

Get the most out of this tool

Ready to generate your GraphQL schema?

Free forever. No signup. Instant results.

Open GraphQL Schema Generator

Understanding GraphQL schema generation from JSON

GraphQL uses a strongly-typed schema language (SDL — Schema Definition Language) to describe API data shapes. Unlike REST APIs where the response structure is implicit and documented externally, GraphQL APIs require every type to be explicitly defined before the server can respond to queries. Generating a GraphQL schema from JSON response data jump-starts this type definition process by inferring types from actual response examples.

The SDL type mapping from JSON follows clear rules: JSON strings become String, JSON numbers become Int or Float (based on whether the number has a decimal component), JSON booleans become Boolean, JSON null indicates that a field is nullable (the type is not marked with !), JSON objects become GraphQL types, and JSON arrays become GraphQL list types (enclosed in []). Fields that are never null in the sample data are marked non-nullable with !.

GraphQL's non-null modifier (!) is a critical design decision. In GraphQL, all fields are nullable by default — a field marked String can return either a string or null. Adding ! makes the field non-nullable: String! guarantees the resolver will always return a string. Schema-first design typically marks required fields as non-nullable, which communicates the contract to clients and enables stricter code generation. Over-using nullable fields produces schemas that force clients to check for null everywhere.

Naming conventions in GraphQL SDL differ from JSON conventions. GraphQL type names use PascalCase (e.g., UserProfile), while field names use camelCase (e.g., firstName). JSON keys may use snake_case (e.g., first_name) or camelCase depending on the backend language. When generating a GraphQL schema from snake_case JSON, the generator should convert key names to camelCase to follow GraphQL conventions — with @deprecated directives or resolver mapping for backward compatibility.

The ID scalar type in GraphQL represents unique identifiers. While ID is serialized as a string in JSON, it semantically differs from a plain String — IDs are typically opaque, not human-readable, and not intended for display. A smart schema generator detects fields named id, _id, or matching the pattern *Id and maps them to the ID scalar rather than String, improving the generated schema's semantic accuracy.

Custom scalars extend GraphQL's built-in type system for domain-specific values. The Date, DateTime, URL, Email, and JSON scalars are common additions. The built-in GraphQL scalars (String, Int, Float, Boolean, ID) cannot represent ISO 8601 date strings with semantic date meaning — a DateTime custom scalar allows clients to know that a value is a date and enables date-aware code generation. Schema generators often detect ISO date strings and suggest custom scalar types.

Schema stitching and federation extend generated schemas to compose multiple GraphQL services into a unified graph. Apollo Federation allows each service to own part of the schema and declare references to types owned by other services using @key directives. A generated schema from one service's JSON output is a starting point — federation directives, resolver implementations, and type references to other service schemas must be added manually to complete the federated type definitions.

When GraphQL schema generation from JSON is useful

Wrapping existing REST APIs with GraphQL Teams adding a GraphQL layer over existing REST endpoints use JSON response samples to generate initial GraphQL types. The generated types define the Query return types, which resolver functions then populate by calling the underlying REST endpoints.
Schema-first API design starting point In schema-first development, the GraphQL schema is defined before implementation begins. Generating an initial schema from design mockup data or existing REST responses provides a concrete starting point for team review and refinement rather than writing SDL from scratch.
Code generation for client applications Tools like GraphQL Code Generator use the schema to produce type-safe TypeScript interfaces, React hooks, and API client code. A complete and accurate schema is prerequisite to code generation — generating the schema from actual response data ensures the generated client code matches what the server returns.
Learning GraphQL SDL syntax Developers new to GraphQL use the converter to understand how familiar JSON structures map to SDL types. Seeing the generated SDL for their own data structures accelerates learning GraphQL's type system, non-null modifiers, and naming conventions through concrete examples.

GraphQL schema design pitfalls

Additional frequently asked questions

What is the difference between a GraphQL schema and a JSON Schema?

GraphQL Schema (SDL) defines types for a GraphQL API — it specifies Query and Mutation operations, object types, scalar types, and resolver contracts. JSON Schema validates arbitrary JSON documents against structural and value constraints. They serve different purposes: use GraphQL SDL for GraphQL API design and code generation; use JSON Schema for validating JSON data in any context including REST APIs.

Can I use the generated schema directly in production?

The generated schema provides types and fields but is not directly deployable — it lacks resolver implementations, authentication directives, deprecation annotations, and business logic constraints. Use the generated schema as a starting point: add Query and Mutation type definitions, implement resolvers, add authorization directives, and refine nullability before deploying to production.

How does the generator handle arrays of mixed types?

GraphQL arrays must have a single element type — [String] is a list of strings, not a list of mixed types. When the JSON sample contains an array with mixed types (strings and numbers, or objects with different shapes), the generator may produce JSON as the element type (a custom scalar) or use a union type. Review mixed-type arrays and define explicit union types for better type safety.

How do I handle GraphQL interfaces and unions from JSON?

GraphQL interfaces and unions represent polymorphic types — fields that can return different object types based on a discriminator. JSON samples showing different object shapes at the same field position suggest an interface or union is needed. Define a union Result = TypeA | TypeB or an interface with shared fields, then add __resolveType to determine the concrete type at runtime based on a discriminating field.