JSON to GraphQL Converter Online — Generate Schema from JSON

Paste any JSON document and emit a GraphQL Schema Definition Language (SDL) with inferred scalars, lists, and nested object types — 100% in your browser.

What is a JSON to GraphQL converter?

A JSON to GraphQL converter reads a JSON document and produces a GraphQL Schema Definition Language (SDL) that describes the same shape using GraphQL types, scalars, and lists. It walks every nested object, infers Int / Float / String / Boolean / ID scalars, and emits one type Foo { ... } definition per object — turning a sample API response into a starting-point schema in a single click.

Schemas almost never start from a blank file. They start from data — a REST response, an OpenAPI spec, a SQL row dump, an export from a SaaS. Hand-translating that data into SDL is mechanical and error-prone. This tool does the mechanical part so you can focus on the interesting bits: deciding which fields are nullable, which strings are really IDs, and where to introduce custom scalars.

How to convert JSON to GraphQL — 4 steps

  1. Paste JSON. Drop a representative JSON object into the input — a real API response works better than a hand-written sample because it covers more types.
  2. Click Convert. The tool walks the document and emits a type for the root and every nested object.
  3. Review the SDL. Check inferred scalars, list element types, and ID detection. Adjust nullability based on real-world responses.
  4. Copy and integrate. Paste the result into your GraphQL server (Apollo, Yoga, Mercurius, Hot Chocolate) and add root Query / Mutation types.

Sample input and output

// Input JSON
{
  "id": "u_42",
  "name": "Alice",
  "age": 29,
  "address": { "city": "SF", "zip": "94102" },
  "posts": [{ "id": "p_1", "title": "Hi", "likes": 42 }]
}
// Output SDL
type Root {
  id: ID!
  name: String!
  age: Int!
  address: Address!
  posts: [Post!]!
}

type Address {
  city: String!
  zip: String!
}

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

Smart Type Inference

Distinguishes Int from Float on the decimal, recognises ID-like keys, and emits the correct list wrapper for arrays of scalars vs arrays of objects.

Nested Type Extraction

Every nested object becomes its own reusable type definition. Arrays of objects are singularised — "posts" becomes type Post — for natural-feeling SDL.

Browser-Only

JSON is parsed and walked entirely in JavaScript on your machine. No upload, no account, no server log of your sample data.

Common use cases

  • check_circleBootstrapping a GraphQL gateway that wraps an existing REST service
  • check_circleGenerating Apollo Server / Yoga / Mercurius schemas from sample API payloads
  • check_circleMigrating from REST to GraphQL incrementally, one resource at a time
  • check_circleConverting Stripe, GitHub, Shopify, and Algolia API responses into typed schemas
  • check_circleDrafting schema documentation from real database row exports
  • check_circleTeaching GraphQL by showing students how shapes map to SDL
  • check_circleProducing a baseline schema for code generators (graphql-codegen, Strawberry, gqlgen)
  • check_circleComparing REST vs GraphQL representations of the same data side-by-side

JSON to GraphQL vs hand-writing SDL

Hand-writing GraphQL SDL is fine for small schemas or when the domain model is well understood. The minute you have more than three or four nested objects — or when the source-of-truth is a JSON sample copied from another service — generating the SDL is dramatically faster. The trade-off: generated schemas are always conservative (everything non-null) because JSON has no nullability metadata. Treat the generator as a 90% solution and finish the remaining 10% — nullability, descriptions, custom scalars, root types — by hand.

Round-trip your schema

Need to go the other way, format an existing schema, or work with the JSON itself? Use the rest of the toolkit.

Frequently Asked Questions

Why generate GraphQL from JSON?

Most schemas start with sample data — a REST response, a database row, an export from a third-party API. Hand-writing the GraphQL SDL for that shape is tedious and error-prone. This tool emits a baseline schema you can copy-paste into a server, refine field by field, and iterate on instead of starting from a blank file.

How are types inferred from JSON?

Booleans become Boolean. Numbers without a decimal point become Int; numbers with a decimal become Float. Strings become String, except keys named "id" or ending in "Id" which become ID. Nested objects become a separate type definition with the parent key turned into PascalCase. Arrays of objects become [Type!]! and arrays of scalars become [Scalar!]!.

What about nullable fields?

JSON has no concept of "this field may sometimes be null." The converter assumes non-null by default and adds an exclamation mark to every field. If a value in the sample is JSON null, the field is emitted as nullable (no !). After generation you should review fields that may be optional in real responses and remove the ! manually.

Are nested types extracted as separate type definitions?

Yes. Every nested object becomes its own "type" block named after the parent key (PascalCased). For arrays of objects, the type is named by singularising the key — "posts" becomes type Post — so the resulting schema is reusable rather than inlined.

Does the tool detect IDs?

Yes, with a simple heuristic: a string field named "id" or ending in "Id" (case-insensitive) is mapped to the GraphQL ID scalar instead of String. After generation, double-check fields like userId and uuid that may also benefit from the ID type.

How are JSON arrays mapped to GraphQL lists?

Arrays become GraphQL list types. The element type is inferred from the first non-null item: an array of strings becomes [String!]!, an array of objects becomes [Type!]!. Empty arrays default to [String] since the element type is unknown — you should override this manually.

Can the schema be used directly in production?

Treat the output as a high-quality starting point, not the final schema. Real GraphQL schemas need root Query / Mutation types, arguments on fields, descriptions, deprecations, custom scalars (DateTime, Email, URL), and union/interface types — none of which can be inferred from a single JSON sample.

Is my JSON sent to your servers?

No. The entire conversion runs in JavaScript in your browser. Open DevTools and watch the Network tab when you click Convert — no requests are made. JSON containing PII, API tokens, or proprietary data never leaves the device.

JSON to GraphQL Converter Online — Generate Schema from JSON