JSON to GraphQL Schema
Generate a GraphQL SDL schema from a JSON sample. Infers types automatically, including nested objects and arrays.
Sample Presets:
23 lines • 395 B
4 types • 27 lines
Valid GraphQL SDL generated successfully
Input Size: 395 BOutput Size: 309 BInferred Types: 4
JSON to GraphQL Schema Generator
This tool analyzes a JSON sample and generates a GraphQL Schema Definition Language (SDL) schema. Type inference rules: JSON numbers without decimals → Int, numbers with decimals → Float, strings → String, booleans → Boolean, nested objects → named types (capitalized key name), arrays → list types. The generated schema is a starting point — you may want to add ! for non-null fields and adjust types for IDs.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Producing a first-draft SDL from a REST response you intend to wrap in a GraphQL layer.
- Generating types for a sample payload to see how the shape maps to a schema.
- Creating a starting point you then annotate with nullability and descriptions.
- Comparing a generated schema against a hand-written one to find omissions.
- Exploring how nested objects become separate types.
Frequently Asked Questions
- How does JSON map onto a GraphQL schema?
- Objects become types, scalars map to String, Int, Float and Boolean, and arrays become list types. Nested objects become their own types, which is why one payload produces several type definitions rather than one.
- Why is every field nullable by default?
- Because a sample cannot show which fields are guaranteed. GraphQL's `!` is a promise you must always keep — a non-null field that comes back null propagates the error up and can null out the whole parent object, so over-promising is worse than under-promising.
- How are IDs recognised?
- By convention rather than by inference — a field called `id` is usually the `ID` scalar. GraphQL's ID is serialised as a string even when the source is numeric, which is deliberate: it signals opacity rather than a type you should do arithmetic on.
- What has no GraphQL equivalent?
- Dates, which need a custom scalar, and arbitrary maps with dynamic keys — GraphQL types are fixed shapes, so a key-value object with unknown keys has no clean representation and is usually modelled as a list of key/value pairs.
- Is a generated schema ready to serve?
- It is a starting point. Real schemas add relationships between types, arguments for filtering, pagination and mutations — none of which appear in a response payload, because they describe capability rather than data.
Common errors and gotchas
- Accepting inferred nullability. GraphQL is explicit about it and a sample cannot tell you what is optional.
- Letting Int and Float be chosen by the sample, where a whole number in one response is fractional in another.
- Shipping generated type names, which are derived from keys and rarely read well.
- Losing union or interface structure, since a generator sees one concrete shape.
- Assuming an empty array tells you its element type. It cannot, so the generator has to guess.
Related Developer Utilities tools
RegExp Tester
Test regular expressions and inspect matches locally.
Regex Visualizer
Visual regex pattern diagram with live match highlighting and capture group annotations.
Subnet Calculator
Compute CIDR subnets, usable hosts, and network ranges.
Cron Parser
Translate cron syntax into plain English.
URL Parser
Break a URL into protocol, host, path, and query parts.
HTML Previewer
Paste HTML and see it rendered live in a safe, sandboxed preview.
HTTP Status Code Reference
Search and look up every HTTP status code and its meaning.
MIME Type Lookup
Find the MIME type for a file extension, or the extensions for a MIME type.