JSON to GraphQL Schema (SDL) Converter
Turn a JSON object into GraphQL type definitions (SDL) with scalar mapping, in your browser.
How to use
- Paste or type your JSON into the input box.
- Optionally rename the root type (defaults to AutoGenerated).
- Copy the generated SDL from the output box.
About this tool
ShowHide
Paste any JSON object or array and get GraphQL type definitions in Schema Definition Language, with scalars mapped and a separate type for every nested object. Whole numbers become Int and fractional ones Float — except integers outside the signed 32-bit range GraphQL's Int allows, such as millisecond timestamps, which become Float too — and keys are rewritten to legal GraphQL names — hyphens and dots become underscores, and a key starting with a digit gains a leading underscore. Where the sample cannot decide a type, a JSON scalar is used and declared for you: that happens for null values and for empty arrays. One thing to add by hand: every field is emitted as nullable, because a value being present in one sample says nothing about whether the API guarantees it, so append the exclamation mark where it belongs. Everything runs locally in your browser — your JSON is never uploaded.
Frequently asked questions
How are numbers typed?
Whole numbers become Int and numbers with a decimal point become Float. Int is a signed 32-bit type in GraphQL, so a whole number beyond ±2,147,483,647 (a millisecond timestamp, a large byte count) becomes Float as well. Adjust manually if you need a different scalar.
What happens with null, empty arrays, or empty objects?
They map to a custom JSON scalar (or [JSON] for empty arrays), since their type can't be inferred. A scalar JSON declaration is added when used.
Are fields nullable?
Yes. GraphQL fields are nullable by default, so no non-null (!) markers are added. Add them manually where a value is always required.
Is my JSON sent anywhere?
No. Conversion happens entirely in your browser; nothing is uploaded.
Why is every field nullable when my API always returns them?
Because one sample cannot prove that. Nullability in GraphQL is a contract, not a description: marking a field non-null promises it will never be absent, and breaking that promise later is a breaking schema change. Add the exclamation mark deliberately, field by field.
What happened to my key with a hyphen in it?
GraphQL names allow only letters, digits and underscores, and cannot start with a digit, so a hyphen or dot becomes an underscore and a leading digit gains one. That renames the field, so the resolver has to map it back to the original key explicitly.
Related tools
JSON → TypeScript Interface
Generate TypeScript interfaces from any JSON sample — types are inferred recursively and named after each key.
Developer
JSON to Python Dataclass Converter
Turn a JSON object into Python @dataclass definitions with type hints, in your browser.
Developer
JSON to Protobuf Schema Converter (proto3)
Turn a JSON object into a proto3 .proto schema with typed fields and nested messages, in your browser.
Developer
JSON to Zod Schema Generator
Turn a JSON object into a Zod validation schema with inferred types, in your browser.
Developer
JSON to Mongoose Schema Generator
Turn a JSON object into a Mongoose schema with type-mapped paths, in your browser.
Developer
JSON Schema Generator
Paste any JSON and get a draft-07 JSON Schema that matches its shape — types inferred, formats detected, required fields filled in.
Developer