JSON to GraphQL

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 Converter

GraphQL type definitions in four steps

Paste your JSON Drop any valid JSON object or array into the input — as compact or pretty-printed as you like.
Select GraphQL output Switch to the Convert tab and choose GraphQL. SDL type definitions are generated immediately.
Copy the type definitions One-click copy puts the generated GraphQL SDL on your clipboard, ready to paste into your server.
Add to your GraphQL server Paste the SDL into your typeDefs, write resolvers, and your GraphQL API is ready to query.

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

JSON to TypeScript Generate typed TypeScript interfaces from your JSON structure instantly.
JSON to OpenAPI Generate OpenAPI schema definitions from JSON samples for your REST API docs.
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

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.

Generate GraphQL types from JSON
Input
{
  "id": 1,
  "name": "Alice",
  "email": "alice@test.com",
  "posts": [
    {"id": 1, "title": "Hello"}
  ]
}
Output
type User {
  id: Int!
  name: String!
  email: String!
  posts: [Post!]!
}

type Post {
  id: Int!
  title: String!
}

Get the most out of this tool

Ready to generate your GraphQL schema?

Free forever. No signup. Instant results.

Open JSON to GraphQL Converter

GraphQL 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

Wrapping a REST API with GraphQL Generate GraphQL types from existing REST API JSON responses. Use these types in your GraphQL schema when building a GraphQL layer over legacy REST endpoints, or when using tools like REST Data Source in Apollo Server.
Schema-first API development Define your data model in JSON first (fast to iterate), convert to GraphQL SDL, then implement resolvers. The generated types give you a head start on the schema before writing any resolver code.
GraphQL Federation type extension When extending a federated GraphQL subgraph with new types from a REST service, generate the type definitions from the REST API's JSON response to quickly add the new entities to your federation schema.
Hasura and Fauna schema setup Database-backed GraphQL platforms like Hasura auto-generate types from your database schema, but you may need to define types for external data sources. Generate GraphQL types from external API JSON to configure Hasura's remote schemas.

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.