Loading GraphQL to JSON Schema Converter...

How to Convert GraphQL to JSON Schema - Step by Step Guide

Step 1

Input Your GraphQL Schema

Start with your GraphQL schema definition. Whether you're working with Apollo Server, need to validate schemas, or want to generate JSON Schema docs, you have several options:

Paste directly: Copy your GraphQL type definitions and paste into the editor
Upload a file: Click "Upload" to select a .graphql or .gql schema file
Try the sample: Click "Sample" to see conversion in action

Example: GraphQL Schema Input

Here's a sample GraphQL type:

type User {
  id: ID!
  name: String!
  email: String!
  age: Int
  posts: [Post!]!
}
Step 2

Automatic Conversion

The converter automatically transforms your GraphQL types to JSON Schema:

Type mapping: GraphQL types become JSON Schema types with proper structure
Required fields: Non-null fields (!) become required properties
Array handling: GraphQL lists become JSON Schema arrays

Example: JSON Schema Output

The converted JSON Schema with validation rules:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id": { "type": "string" },
    "name": { "type": "string" }
  },
  "required": ["id", "name"]
}
Step 3

Review and Customize

Verify the generated JSON Schema:

Valid JSON Schema: Output follows JSON Schema specification
Type definitions: All GraphQL types mapped correctly
Validation ready: Use for API validation and documentation
Step 4

Export and Use

Get your JSON Schema ready for use:

Copy to clipboard: One-click copy for pasting into your project
Download as JSON: Save as .json file for your documentation
API validation: Use with validation libraries like Ajv or Joi

Frequently Asked Questions

Why convert GraphQL to JSON Schema?

JSON Schema is widely used for API validation, documentation generation, and data validation across different systems. Converting GraphQL schemas to JSON Schema allows you to use the same type definitions for REST APIs, validation libraries, and documentation tools that don't natively support GraphQL.

How are GraphQL types mapped to JSON Schema?

GraphQL String, ID become JSON Schema "string", Int and Float become "number", Boolean becomes "boolean". Non-null fields (!) are added to the "required" array. GraphQL lists become JSON Schema arrays with "items" definitions. Custom types become nested object schemas.

Can I validate data with the generated JSON Schema?

Yes! The generated JSON Schema is fully valid and can be used with any JSON Schema validator like Ajv, json-schema, or tv4. It's perfect for validating API requests, responses, and configuration files. You can also use it with JSON validation tools.

Does the converter handle complex GraphQL schemas?

Yes! The converter handles nested types, enums, interfaces, unions, and custom scalars. It properly converts complex type relationships into JSON Schema definitions with $ref references where appropriate.

Is the generated JSON Schema compatible with OpenAPI?

Yes! The generated JSON Schema follows the specification used in OpenAPI/Swagger, making it compatible with API documentation tools and REST API frameworks. You can format your GraphQL first for better results.

Is this tool free to use?

Yes, completely free with no limitations on schema size or conversion frequency. No registration required, and you can convert unlimited GraphQL schemas to JSON Schema.