JSON to GraphQL

Processed locally
app.graphql.view

You can also load data via #data={"name":"Ada"} or #url=... It is cleared from the address bar after it is read.

Infer GraphQL types from a JSON sample. Faster than writing types from scratch when you debug a GraphQL response or draft a mock service. Objects become named types; arrays become lists.

Scalar inference

Strings, numbers, and booleans map to GraphQL scalars. Nested objects become separate types instead of collapsing to JSON.

Confirm whether null and mixed types should become union types.

Nested types

Objects become named types; arrays become lists. Deep structures produce several type blocks you can paste into a schema file as a draft.

Whether a field is non-null ( ! ) should be completed from the product.

A starting point

After generation, add ! for required fields, enums, and custom scalars. This page has no query / mutation root operations.

REST teams that only need a JSON contract should use the Schema page.

Example

Sample JSON
{
  "user": {
    "id": "u_1",
    "name": "Ada"
  }
}
Possible type draft
type User {
  id: String
  name: String
}

type Root {
  user: User
}
Is this a complete GraphQL schema?

It is only types inferred from data shape. There are no query / mutation operations.

How do I choose versus JSON Schema?

REST docs usually use Schema. GraphQL services fit this page better.

Are field names legal?

Identifiers are generated to be usable. Rename odd keys to GraphQL-legal field names by hand.

Is the sample uploaded?

No. Inference runs in the browser.

Recommended workflow

  1. Copy a typical response from a GraphQL playground or logs.
  2. Generate types and check that nesting is split and lists are correct.
  3. Add required, enums, and custom scalars, then write them into the server schema.
  4. For REST docs, use the JSON Schema page instead.

One response cannot produce a complete graph. Mutation inputs and pagination still need to be written by hand.