GraphQL Schema to JSON Mock Generator
Paste your SDL schema and get a live JSON mock response. Real-time, client-side, no install required.
The Complete Guide to GraphQL Schema Mocking
Modern API development rarely has frontend and backend teams finishing work at the same time. The schema is agreed on first - it is the contract between client and server. This tool turns that schema contract into usable mock data instantly, letting your frontend team write real components against real data shapes before a single resolver is implemented.
How to Use This Tool
Paste any valid GraphQL SDL schema into the left panel. The tool parses it in real time and generates a JSON mock response in the right panel. The output mirrors exactly the shape a real GraphQL API would return, starting from the Query root type (or the first defined type if your schema has no Query).
Use the List Length slider to control how many items appear in array fields. Use the Nesting Depth slider to limit how deeply nested objects are generated - especially important for schemas with circular references like User.friends: [User]. Switch between Smart Data (field-name heuristics) and Static Types (bare placeholder values) depending on whether you need presentable output or just shape verification.
How the SDL Parser Works
The tool includes a complete custom SDL tokenizer and recursive-descent parser written in plain JavaScript - no external libraries, no network calls. The tokenizer reads your schema character by character, discarding comments (lines starting with #) and block-string descriptions ("""..."""), then produces a flat stream of tokens: names, punctuation marks, and structural characters.
The parser then walks that token stream to reconstruct the type graph: object types, enum types, union types, interface types, and custom scalars. Fields are read with their full type references, including list wrappers ([Post!]!) and non-null modifiers (!). Directives and argument definitions on fields are gracefully skipped since they do not affect the mock output shape.
Smart Data Field Heuristics
In Smart Data mode, the mock engine inspects each field name before deciding what value to generate. A field named email returns [email protected]. A field named createdAt returns an ISO 8601 timestamp. A field named avatar returns a plausible image URL. A field named slug returns sample-slug. These heuristics make the mock output readable enough to paste directly into a Figma mockup or share in a Slack design review without looking like raw placeholder data.
Circular Reference Protection
The mock generator uses two complementary defenses against infinite recursion. The Nesting Depth slider sets a hard limit on how many levels deep the generator will traverse from the root. Separately, a per-branch visited-type set tracks which types are already being built on the current stack. If the generator encounters a type it is already building (indicating a cycle), it substitutes null immediately rather than recursing. This means User.friends[0].friends[0] will stop building at the depth limit, never spiraling forever.
Reading the Generated Output
The JSON output wraps everything in a data envelope, matching the actual response format a GraphQL server returns. Each field on the Query type becomes a top-level key inside data. If your schema has a Query type with user and posts fields, the output will have data.user as an object and data.posts as an array with as many items as your List Length slider specifies.