JSON to GraphQL Types
Infer GraphQL types from JSON.
About this tool
Paste a JSON object and get a GraphQL type definition (SDL) with one field per key. Numbers map to Float, arrays to lists, and nested objects to a JSON scalar that you must define yourself.
How to use
How it works
Keys become fields: strings become String, integers and decimals both become Float, booleans become Boolean, arrays become [T] using the first item, and nested objects become JSON. The type is named Root. Fields are nullable, since the tool never adds a trailing exclamation mark.
Worked example
A user with a nested object
- Input
- {"id":1,"name":"Ada","score":9.5,"tags":["a"],"owner":{"x":1}}
- Output
- type Root { id: Float name: String score: Float tags: [String] owner: JSON }
- Walkthrough
- id is Float because integers and decimals are not distinguished; change it to Int or ID. owner is JSON because nested objects are not expanded.
Limitations
- No Int, ID or non-null (!) types are inferred.
- Nested objects are not turned into their own types.
- The JSON scalar is not declared in the output.
- Only the first array item is used.
Questions
How do I generate a GraphQL type from JSON?
Why are my integers Float?
What does JSON mean in the output?
Are fields non-null?
Features
- Lists from arrays
- Float, String, Boolean mapping
- Runs in your browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
Learn Regular Expressions - Crash Course
freeCodeCamp.org
Regex primer for tester and explainer pages.
Watch on YouTubeSQL Tutorial - Full Database Course
freeCodeCamp.org
JSON often lands next to SQL exports when debugging data pipelines.
Watch on YouTube
- web.dev
Google
Modern web guidance that pairs with encoding and tooling pages.
- Introduction to JSON Web Tokens
jwt.io
JWT structure for decoder and debugger pages.