What this does
Infers GraphQL schema definition language (SDL) types from a JSON sample. Nested objects become separate type declarations named after their field (a field calledorders holding objects produces type Order), and arrays become lists.
Example
Input
{
"id": 42,
"name": "Ada",
"verified": true,
"tags": [
"admin",
"dev"
],
"orders": [
{
"sku": "A1",
"qty": 2
},
{
"sku": "B2",
"qty": 1,
"note": "gift"
}
]
}Output with default options
type Root {
id: ID!
name: String!
verified: Boolean!
tags: [String!]!
orders: [Order!]!
}
type Order {
sku: String!
qty: Int!
note: String
}
Inference rules
- Scalars: strings are
String, booleansBoolean. Numbers areIntonly if every value is an integer within GraphQL's 32-bit range; otherwiseFloat. - ID: fields named
idholding strings or integers becomeID(switch off if you do not want that). - Nullability: a field present in every object and never
nullgets!. When an array holds several objects, a key missing from any of them, or null in any of them, stays nullable. Turn the option off to leave everything nullable. - Lists: elements of all arrays at the same position are merged, so
[Order!]!reflects the union of the objects. - Unknowns: null-only values, empty arrays, empty objects, and mixed-type values use a custom
scalar JSON, which the tool declares and flags for you. - Keys that are not valid GraphQL names are renamed with underscores and listed in a note. The root must be an object or an array of objects.
Things to know
The output only contains type definitions, not Query or Mutation roots, since those depend on how you expose the data. Inference is only as good as the sample, so paste several records for realistic nullability.
Privacy
The conversion runs in your browser. The JSON is never uploaded.