GraphQL Variables Validator
Check a GraphQL variables JSON document against an operation's variable declarations: missing required values, extra keys and wrong types.
What the GraphQL Variables Validator does
The operation's declarations are parsed from the document: name, type and whether a default is present. A variable with a default may be omitted; a non-null variable without one may not.
Types are checked rather than coerced: an Int must be a 32-bit integer, a Float a finite number, a String a string, a Boolean true or false, and a list an array whose items pass the inner check.
Enum values and custom scalars are accepted as strings: without a schema this page cannot know an enum's members. Input object types are accepted as objects without a field-level check.
How to use it
Paste the variables JSON into the Variables JSON box, and the operation into the Operation box if it is not already there.
Press Run and read the Validation report: one line per declared variable, saying ok, omitted or refused.
Check the Validation report for a key you were unsure about — an undeclared key is named, because a typo there is a variable the server never receives.
Worked example
Input:
{"episode":"JEDI"}
Output:
Operation: Hero
episode: ok as String!
limit: omitted, using the declared default
{
"episode": "JEDI"
}
Why it runs in your browser
The result is produced on this page with JavaScript, so it works offline after the page loads and nothing you enter is sent anywhere.
Paste an operation and its variables: every declared variable is checked for presence and type, and every key you sent that the operation does not declare is refused.
The report says why each variable passed — the declared type it was checked against — so a green run is checkable, not just green.
What it does, and what it does not
The operation's declarations are parsed from the document: name, type and whether a default is present. A variable with a default may be omitted; a non-null variable without one may not.
Types are checked rather than coerced: an Int must be a 32-bit integer, a Float a finite number, a String a string, a Boolean true or false, and a list an array whose items pass the inner check.
Enum values and custom scalars are accepted as strings: without a schema this page cannot know an enum's members. Input object types are accepted as objects without a field-level check.
How to use GraphQL Variables Validator
Paste the variables JSON into the Variables JSON box, and the operation into the Operation box if it is not already there.
Press Run and read the Validation report: one line per declared variable, saying ok, omitted or refused.
Check the Validation report for a key you were unsure about — an undeclared key is named, because a typo there is a variable the server never receives.
What to Expect
Best for
- Catching a missing required variable before sending a request
- Finding a typo in a variable name
Not ideal for
- Validating a value against an enum's members, which needs the schema
- Checking input object fields, which are not inspected
What this tool keeps
- The declared type each variable was checked against
- The normalised JSON document you sent
What may need cleanup
- An enum value still needs checking against the schema by hand
- An input object's inner fields are not verified
Common errors
- The page refuses it: required variable episode is missing
Example use cases
- Checking a variables file before a manual GraphQL call
- Finding the variable a 400 error is complaining about
Sample input
Variables JSON: {"episode":"JEDI"}
Sample output
Validation report: Operation: Hero …
Who this is for
- Developers testing a GraphQL operation by hand
- Anyone debugging a variables document in CI
Frequently asked questions
What happens to a variable with a default?
It may be omitted: the report says the declared default is used. If you send it, its type is still checked.
Why is an undeclared key an error?
The operation cannot receive it, so a typo silently drops the value. Naming the key is the fastest way to see what the server never got.
Does it need the schema?
No. Variable declarations are part of the operation document, which is enough to check presence and scalar types; enum members and input object fields are the two things it cannot check.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.