How to use GraphQL Query Formatter and Validator
- Paste a GraphQL document or choose one UTF-8 .graphql, .gql or text file. A selected file replaces the pasted document.
- Choose two or four indentation spaces and a preferred line width from 40 to 120. Optionally enter Variables JSON as an object.
- Read the formatted document or syntax error, then copy or download formatted-query.graphql. Check fields, argument types and variable values against your intended API schema separately.
Example: GraphQL Query Formatter and Validator
Format a named GetUser query while preserving its $id variable and selected fields.
Options
- Document input
- The parser handles GraphQL syntax rather than contacting an endpoint. Pasted source is limited to 100,000 characters; a selected UTF-8 file is limited to 100,000 bytes and replaces the text.
- Indentation and width
- Choose two or four spaces and a whole preferred width from 40 to 120. A formatter’s preferred width is not a strict limit for every string or expression.
- Variables JSON
- Optional, up to 100,000 UTF-8 bytes, and it must be a JSON object. This checks the supplied JSON structure only. It does not check GraphQL variable names, required values or types against a schema, and variables are not sent anywhere.
Supported inputs and limits
- GraphQL source up to 100,000 characters, 2,000 scanned tokens and 100 nesting levels.
- A selected UTF-8 source file is limited to 100,000 bytes.
- Parsing and formatting use the bundled Prettier GraphQL grammar.
- Optional variables input is checked as a JSON object, not validated against the operation or API schema.
- No schema connection, resolver execution, endpoint request, minification or query-cost analysis occurs.
Where your input is processed
This tool does not upload your inputs. See the limits for anything saved on your device.
A parsed query may still fail against a schema
Syntax can be valid while a field, argument or type is absent from the actual API. This page has no schema and makes no requests. Validate the operation against its intended schema, supply the required variables and review its effects before running it in another system. Formatting does not estimate query cost.
Questions about GraphQL Query Formatter and Validator
Does valid syntax prove a query will work?
No. The server schema and variable values must also match.
Will the query be sent to an endpoint?
No. Syntax processing happens in this browser.
Does formatting execute mutations?
No. It changes source layout without running any operation.