Generate GraphQL Schema
from JSON
Paste any JSON and instantly get GraphQL type definitions. Perfect for API developers building GraphQL servers from existing JSON data sources.
Open JSON to GraphQL ConverterGraphQL type definitions in four steps
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, GraphQL.js, Hasura, and all major GraphQL implementations.
Works Offline
Load once and use forever — even on a plane or without internet access.
Related JSON tools
Common questions answered
Is JSON to GraphQL conversion free?
Yes, completely free with no account required.
What GraphQL spec version is generated?
The output uses GraphQL Schema Definition Language (SDL), compatible with all major GraphQL implementations including Apollo, GraphQL.js, and Hasura.
Does my data leave my browser?
No. All conversion is 100% client-side.
How are nested JSON objects handled?
Each nested object becomes a separate GraphQL type definition. Arrays become list types (e.g., [String]).
Can I use the output directly in Apollo Server?
Yes. Paste the generated SDL into your typeDefs and add resolvers to create a working GraphQL API.
Converting JSON to GraphQL types
GraphQL uses a strongly-typed schema to define queryable data. Each type has field names and types (String, Int, Float, Boolean, ID). This tool generates GraphQL type definitions from JSON, mapping structures to the GraphQL type system — useful when building a GraphQL API from existing JSON data.
The converter maps JSON types to GraphQL: strings → String, numbers → Int or Float, booleans → Boolean, arrays → [Type], nested objects → separate types. Nullable fields use default behavior (nullable unless !). Output is valid SDL for Apollo Server, graphql-yoga, or any framework.
{
"id": 1,
"name": "Alice",
"email": "alice@test.com",
"posts": [
{"id": 1, "title": "Hello"}
]
}
type User {
id: Int!
name: String!
email: String!
posts: [Post!]!
}
type Post {
id: Int!
title: String!
}
Get the most out of this tool
- GraphQL fields are nullable by default — add ! to required fields manually after generating base types.
- Use separate type definitions for nested objects — it makes the schema reusable across queries.
- Add Query type definitions manually to specify which types are accessible as top-level queries.
Ready to generate your GraphQL schema?
Free forever. No signup. Instant results.
Open JSON to GraphQL ConverterGraphQL type definitions from JSON
GraphQL is a query language for APIs that uses a strongly typed schema to define the shape of all data. Unlike REST APIs where the server decides what data to return, GraphQL lets clients specify exactly which fields they need. Every piece of data in a GraphQL API must be described in the schema using type definitions — this is where converting existing JSON data structures to GraphQL types saves significant development time.
The converter maps JSON structures to GraphQL SDL (Schema Definition Language) type definitions. JSON objects become GraphQL types with fields. JSON strings become the String scalar. JSON integers become the Int scalar. JSON floats become the Float scalar. JSON booleans become the Boolean scalar. JSON arrays of primitives become lists: [String], [Int]. JSON arrays of objects become lists of named types: [User]. Nested JSON objects become separate named types.
GraphQL's type system has an important distinction from JSON: non-nullable by default with optional explicit nullability. In GraphQL SDL, a field declared as name: String! is non-null (cannot return null). Without the exclamation mark, name: String is nullable (can return null). This is the opposite of TypeScript's default behavior. The converter marks fields as nullable unless all records in a provided JSON array have that field present and non-null.
The ID scalar is GraphQL's special type for unique identifiers. It accepts both integers and strings but always serializes as a string. JSON fields named "id", "_id", or ending in "Id" or "_id" are typically converted to the ID scalar rather than String or Int. This is a naming convention that this converter follows — fields that appear to be identifiers get the ID type for proper GraphQL semantics.
Custom scalars allow GraphQL to represent types beyond the five built-in scalars (String, Int, Float, Boolean, ID). Date, DateTime, JSON, UUID, URL, and Email are common custom scalars defined in many GraphQL schemas. Fields that look like dates, emails, or URLs in the JSON input are flagged as candidates for custom scalars in the converter output — you replace the generated String type with your preferred custom scalar.
GraphQL type definitions generated from JSON are the starting point for a GraphQL API, not the complete schema. You still need to define Query, Mutation, and Subscription types that reference your data types. You need to define resolvers that fetch and return data. You need to add directives for deprecation, authorization, and caching. But starting with generated types from real JSON data ensures your type definitions match the actual shape of your data from the beginning.
When developers use this tool
Additional frequently asked questions
What is the difference between a GraphQL type and an interface?
A GraphQL type (type keyword) is a concrete object type with defined fields. A GraphQL interface (interface keyword) is an abstract type defining fields that implementing types must include. Use interfaces when multiple types share common fields (like a Node interface with an id field). The converter generates concrete types by default — you convert to interfaces manually when modeling inheritance hierarchies.
How does GraphQL handle JSON data that does not fit a schema?
GraphQL is strictly typed — every field must be declared in the schema. For truly dynamic JSON data with arbitrary structure, the JSON scalar (a custom scalar that accepts any valid JSON) is the escape hatch. Declare the field type as JSON and the resolver can return any JSON-serializable value. This loses type safety but allows flexibility for schema-less content like metadata or user-defined attributes.
Can I use the generated GraphQL types with Apollo Client?
Yes. Apollo Client's TypeScript integration generates TypeScript types from your GraphQL schema and operations. Once you've defined your GraphQL schema using the generated types, run Apollo's codegen to produce TypeScript interfaces for your queries. The generated GraphQL types are the foundation that enables end-to-end type safety from schema to component.
Does GraphQL support nested objects and arrays?
Yes. GraphQL was designed for hierarchical data. Nested objects become nested type references. Arrays become list types. GraphQL's resolver chain handles nested field resolution — each field in a type can have its own resolver that lazily fetches data only when the client requests that field. This makes GraphQL efficient at fetching only the nested data actually needed.