JSON to GraphQL Schema (SDL)

Infers GraphQL schema definition language from a JSON sample: nested objects become types, arrays become lists, and fields missing in some items become nullable.

Use the tool

Why this tool exists

Say a REST endpoint returns a large JSON document and you are wrapping it in a GraphQL layer. Writing the type definitions by hand means reading the payload, deciding what is a list, what can be null and where an ID belongs. This tool does that first pass for you. It looks at every item in an array, so a key that appears in only some objects is marked nullable, and it tells integers from floats. It also names nested types from the key they sit under. You get a schema skeleton to refine, not a finished design. Your sample stays in the browser, which matters when the payload is a real customer response.

How to use it

  1. Paste a JSON object, or an array of objects, into the sample box.
  2. Set the root type name and tick "Also emit input types" if you need matching input definitions.
  3. Review the generated type blocks and copy them into your schema file.

Frequently asked questions

How does it decide what is nullable?

A field is nullable if it is null in any sample or missing from some objects in an array. Everything else gets a "!" for non-null. A single object gives no hint about optional keys, so provide several examples where you can.

What becomes ID, Int and Float?

A key called "id" becomes ID. Other numbers become Int when every sample value is a whole number and Float otherwise. Strings and anything unclear become String.

Can it produce input types?

Yes. The input option emits an "Input" twin of each type and points nested fields at the matching input types. Check them, since inputs often need fewer fields than outputs.

Does it understand unions or enums?

No. It only sees shapes in the sample, so unions, enums and custom scalars such as dates have to be added by hand. Dates will appear as String.