Generate mock JSON from a GraphQL SDL schema

Paste your SDL and get realistic, reproducible mock data — one object per type, a single named type, or a full query response envelope. Interfaces, unions, enums, custom scalars and @fake / @examples / @listLength directives all resolve.

Try:
Mock JSON

About this tool

This tool reads a GraphQL SDL schema and writes mock JSON that matches it. Paste the schema you already have — type, interface, union, enum, input, scalar, schema and extend definitions, with descriptions, comments, field arguments and directives — and pick what you want out: one mock object per type in the document, a single named type, or a full {"data": ...} response envelope for the Query root.

Everything runs in your browser. The schema is never uploaded, and output is deterministic: the same schema plus the same seed always produces byte-identical JSON, so you can paste the result straight into a test fixture or a snapshot without it churning on every run.

Nullable and non-null fields are treated differently on purpose. Non-null fields (String!) always get a value; nullable fields follow the Nullable fields control, so you can fill them, force every one of them to null, or leave them out of the object entirely — three shapes that exercise very different client code paths.

Worked example

Paste this schema, set What to generate to Query response envelope, and leave the other controls at their defaults (2 items per list, depth 3, nullable fields filled, smart values on, seed 1):

type Query {
  user: User
}

type User {
  id: ID!
  fullName: String!
  email: String!
  role: Role!
}

enum Role { ADMIN EDITOR VIEWER }

Output:

{
  "data": {
    "user": {
      "email": "[email protected]",
      "fullName": "Mia Evans",
      "id": "e99ff867-dbf6-42c9-b82f-f84cb27281e9",
      "role": "ADMIN"
    }
  }
}

ID! became a v4 UUID, Role! was drawn from the enum's own values rather than invented, and email/fullName were shaped from the field names because Infer realistic values from field names is on. Change the seed to get a different-but-equally-stable fixture.

Field-name inference and faker directives

With smart values on, field names steer the generator: email, phone, avatarUrl, slug, username, firstName, city, country, postcode, currency, locale, timezone, color, ip, token, status, createdAt, birthday, description, title and id all get appropriately shaped values, and numeric names such as age, year, percent, count, price, rating, latitude and longitude get plausible ranges. Turn the option off for neutral placeholder text when you want the shape without the flavour.

Per-field directives override both, using the vocabulary SDL mock servers already use:

Well-known custom scalars are shaped by name too, with no configuration: DateTime, Date, Time, UUID, URL, Email, JSON, BigInt, Decimal, PhoneNumber, HexColor, Base64 and Upload among them. Any other scalar Foo becomes the clearly-labelled string mock-foo, so an unhandled scalar is visible in the output rather than silently plausible.

Limits and edge cases

FAQ

Why does the same schema keep giving me the same JSON?

Because that is the point. Output is seeded, so a schema plus a seed is a stable fixture you can commit and diff. Change the Seed value to get a different dataset, or bump it in a loop to generate a set of distinct-but-reproducible records.

How do I mock the response to one specific query?

Choose Query response envelope to get {"data": {...}} covering every field on the Query root, then delete the fields your query does not select. This tool mocks the schema, not a query document — it has no selection-set executor, so it cannot trim the response for you.

My schema has `scalar DateTime` — do I need to configure it?

No. Common scalar names are recognised case-insensitively and shaped accordingly, so DateTime becomes an ISO-8601 timestamp and URL becomes a URL with no setup. An unrecognised scalar becomes mock-<name> so you can see at a glance that it needs attention.

What is the difference between the three nullable-field modes?

Fill generates a value for every nullable field, which is the friendliest default for a UI fixture. Force to null sets each one to JSON null, which is the fastest way to check that your client handles missing optional data. Leave them out omits the keys entirely, which is what a real server does for fields a query did not select. Non-null fields are always generated in all three modes.

Will it handle interfaces and unions?

Yes. An interface is mocked as the first object type that implements it, and a union as its first listed member, with __typename always included so the chosen shape is explicit. If you need a different member, put that type first in the document or mock it directly with single-type mode.

Is my schema uploaded anywhere?

No. The generator is compiled to WebAssembly and runs entirely in your browser tab, so the schema text never leaves your machine. The same code is available offline through the command line tool.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool graphql-mock-from-sdl "type Query {
  user: User
}

type User {
  id: ID!
  fullName: String!
  email: String!
  role: Role!
}

enum Role { ADMIN EDITOR VIEWER }"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/graphql-mock-from-sdl/?sdl=type%20Query%20%7B%0A%20%20user%3A%20User%0A%7D%0A%0Atype%20User%20%7B%0A%20%20id%3A%20ID%21%0A%20%20fullName%3A%20String%21%0A%20%20email%3A%20String%21%0A%20%20role%3A%20Role%21%0A%7D%0A%0Aenum%20Role%20%7B%20ADMIN%20EDITOR%20VIEWER%20%7D&mode=all-types&type_name=User&list_length=2&depth=3&nullable_fields=fill&smart_values=true&typename=true&seed=1&pretty=true

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.