ToolConvoyToolConvoyv2.6
DEV

JSON to GraphQL — Generate GraphQL Schema from JSON

Generate GraphQL schema type definitions from JSON data. Nested object types, arrays, nullable fields — in your browser, no upload.

● LOCAL · GENERATED IN YOUR TAB0 network requests from tools since page load

JSON to GraphQL Schema

Generate GraphQL schema type definitions from JSON data. Auto-detects types, nullable fields, arrays, and nested objects. Works entirely in your browser.

GraphQL schemas are the strongest contract in modern web API design. The schema defines every type, every field, every argument, and every possible response shape, and clients and servers generate code from the same schema to guarantee that the API surface stays consistent. Writing the schema by hand from a sample API response is the first step in adopting GraphQL for an existing REST or RPC API, and the generated schema serves as the scaffold for the resolver map. The generator walks a JSON response, infers the GraphQL type system for each nested object, and emits an SDL file that the server-side resolver can read immediately.

The GraphQL-specific concern that matters most in practice is nullable-by-default versus non-nullable-by-default. A non-nullable field (String!) tells the client that the field is always present — a promise the server must keep for every request. Changing a non-nullable field to nullable later is a breaking change. The generator defaults to non-nullable for fields that are present in every element of the sample array, but the safer choice for evolving APIs is to make every field nullable and let the client deal with absent values gracefully. The nullable toggle in the options exists for this reason — choose it if your API is still in development and the response shape may change.

The most common downstream step after generating a schema is to plug it into a code-generation pipeline: graphql-codegen for TypeScript clients, gqlgen for Go servers, or apollo-tooling for the Apollo ecosystem. The generated SDL is the input to all three. If the destination is a mock server, the companion JSON-to-TypeScript converter can generate TypeScript types from the same JSON sample, so the mock server’s return types and the GraphQL schema are defined from the same source.

Advertisement

How to use

  1. Paste your JSON API response

    Drop a JSON object from a REST or GraphQL endpoint. The generator walks the structure and emits a GraphQL schema with type definitions for each nested object shape.

  2. Choose schema style

    Toggle between SDL (Schema Definition Language, the standard .graphql format) and a JSON representation. Enable nullable-by-default for APIs where every field is potentially absent.

  3. Copy the schema

    Copy the SDL or JSON schema to your clipboard. The output is paste-compatible with Apollo Server, GraphQL Yoga, and gqlgen — no extra formatting needed.

Frequently asked

How does it map JSON types to GraphQL scalar types?

JSON strings become `String`, numbers become `Int` or `Float` based on whether the sample contains a decimal point, booleans become `Boolean`, and ISO 8601 date strings are auto-detected and mapped to the custom `DateTime` scalar (you define the scalar in your resolver map).

Does it handle GraphQL lists?

Yes. JSON arrays become `[Type]` in the schema. Arrays of objects become `[NestedType]`. Arrays of scalars become `[String]`, `[Int]`, etc. The generator infers the list element type from the first element in the sample array.

What about GraphQL mutations and queries?

The generator emits type definitions only — not queries, mutations, or subscriptions. Write the resolvers by hand. The types are the input to `graphql-codegen`, `gqlgen`, or your GraphQL library of choice.

Can it generate input types for mutations?

Yes — toggle 'input types' in the output options to emit `input` types instead of `type` definitions. Input types are used in mutation arguments where the client sends data to the server.

How does it determine nullability?

By default, fields that appear in every array element are non-nullable (`String!`), and fields that are absent in some elements are nullable (`String`). Toggle 'nullable-by-default' to make every field nullable — the safer choice for APIs that evolve over time.

Limitations

  • No union or interface typesThe generator emits only object types and scalar types. GraphQL unions (for polymorphic responses) and interface types are not inferred from flat JSON — define these by hand after generation.
  • No enum detectionA string field that only ever takes 'pending', 'active', or 'closed' is emitted as String, not as a GraphQL enum. Review the output and add enums by hand for fields that have a known set of values.
  • Sample-dependent type inferenceA field that is a string in the sample may be an Int in another response from the same endpoint. The generator infers the type from the provided sample only — test with multiple sample responses if your API is inconsistent.

Platform notes

macOS
The generated SDL is paste-compatible with Apollo Studio, GraphQL Playground, and any GraphQL IDE. Use the browser tool for one-off schema generation from a sample API response during prototyping.
Windows
The generated SDL works with Altair GraphQL Client and GraphiQL on Windows. Use it for one-off generation during client-side development where a backend endpoint is not yet documented.
Linux
For command-line work, `graphql-codegen` and `apollo-tooling` can introspect a live endpoint. The browser tool is the right pick when the endpoint is not yet deployed or is behind an auth layer.
Web
Runs entirely client-side. Works offline. Useful for generating schema from a static JSON fixture file during the design phase of an API.
Advertisement
Advertisement