Generate GraphQL Schema from API Response
Convert any REST API JSON response into a complete GraphQL schema definition. The tool infers types, detects IDs and timestamps, and generates Query and Mutation operations — all in your browser.
JSON to GraphQL Schema Generator
Generate GraphQL schema definitions from JSON data. Automatically infers types, detects IDs, dates, and nested objects. Optionally generates Query and Mutation types.
About JSON to GraphQL Schema
- Infers GraphQL scalar types (String, Int, Float, Boolean, ID) from JSON values automatically.
- Detects UUIDs and ID-like fields →
ID, dates →DateTime/Datecustom scalars. - Nested objects become separate GraphQL types. Arrays of objects are merged for complete field coverage.
- Optionally generates Query type (get by ID, list all) and Mutation type (create, update, delete) with input types.
- Download the schema as a
.graphqlfile ready for your server. - Everything runs in your browser — no data is sent over the network.
Why convert JSON to GraphQL?
When migrating from REST to GraphQL or wrapping existing REST APIs with a GraphQL layer, you need schema definitions that match your existing data shapes. Manually writing type definitions for complex nested JSON responses is tedious and error-prone. This tool automates the process by analyzing your JSON structure and generating accurate GraphQL types with proper scalar assignments.
// Generate GraphQL schema from API response
// API response JSON:
// { "users": [{ "id": "u1", "name": "Alice", "posts": [{ "title": "Hello" }] }] }
// Generated GraphQL schema:
type Query {
users: [User!]!
}
type User {
id: ID!
name: String!
posts: [Post!]!
}
type Post {
title: String!
}
// JavaScript — infer types from JSON
function jsonToGraphQLType(obj) {
if (typeof obj === "string") return "String";
if (typeof obj === "number") return Number.isInteger(obj) ? "Int" : "Float";
if (typeof obj === "boolean") return "Boolean";
return "String";
}How type inference works
The generator analyzes each JSON value to determine its GraphQL scalar type: strings become String, integers become Int, floats become Float, booleans become Boolean. Fields named 'id' or ending in '_id' are mapped to the ID scalar. ISO date strings are detected and mapped to custom DateTime or Date scalars. Nested objects become separate GraphQL types, and arrays become list types.
Frequently Asked Questions
Does this tool handle nested JSON objects?
Yes. Each nested object in your JSON becomes a separate named GraphQL type. Arrays of objects are merged across all elements to produce a complete type with all possible fields.
Can I generate Query and Mutation types?
Yes. Enable the 'Generate Query' option to add getById and list queries, or 'Generate Mutations' for create, update, and delete operations with automatically generated input types.
Related Generate Tools
tsconfig.json Builder
Build TypeScript tsconfig.json visually with framework presets, explanations for every option, and one-click download
package.json Generator
Generate package.json visually with framework presets, dependency editor, scripts, and module config
Security Headers Generator
Generate HTTP security headers for Nginx, Apache, Vercel, Netlify, and Cloudflare with presets, security scoring, and multi-format output
HTTP Request Builder
Build HTTP requests visually and generate code in cURL, JavaScript, Python, Go, Rust, and PHP — lightweight Postman/ReqBin alternative