
GraphQL SDL: Validate and Format a Schema Online
SDL syntax errors, schema review and formatting before merge — extends the existing GraphQL beautifier.
Why validate GraphQL SDL before you merge?
A schema that does not parse blocks code generation, fails GraphQL server startup, and turns a review into guesswork. The usual culprits — a missing brace, an unknown type name, a forgotten Query root — hide in a 400-line SDL diff. FastMinify's GraphQL SDL validator runs GraphQL.js buildSchema in your browser: paste the schema document, get a valid/invalid verdict with line and column when GraphQL.js provides them. Formatting stays on Beautify GraphQL (Prettier). There is no separate format-graphql slug. Browse the rest of the cluster from the API tools hub. If you also maintain REST contracts, pair this workflow with the OpenAPI validation guide.
Honest limits and habits that survive code review
A valid verdict means GraphQL.js buildSchema accepted the pasted SDL. It is not a proof that your API behaves correctly in production.
.graphql files, includes, or Git URLsThe browser tool is for a fast loop before git push. Teams still run GraphQL.js, graphql-eslint, or rover in CI as the merge gate.
Query type or a custom schema { query: … }Most SDL incidents are rename leftovers and missing roots, not exotic GraphQL features.
Schema SDL vs queries: two documents, two tools
Schema Definition Language (SDL) describes types, fields, and roots. It is the contract your resolvers must honour — not an executable query. FastMinify validates that contract with GraphQL.js buildSchema, not by talking to a live server.
Query, Mutation, and Subscription when those types exist.graphql files from a URLAn operation document (query, mutation, subscription, fragment) is not schema SDL. Pasting one into the validator fails buildSchema. Format those documents on Beautify GraphQL instead.
buildSchema, no query executionGraphQL.js typically requires a Query root type unless your schema definition names another query type. A document of only type User { … } with no query root usually fails validation — that is expected, not a FastMinify bug.
type Query { hello: String }schema { query: RootQuery } plus type RootQuery { … }Validation answers "is this schema SDL accepted by GraphQL.js?". Beautify answers "is this GraphQL readable?". Indentation never fixes an unknown type.
buildSchema — valid or invalid, issues with line/column when availabletabWidth 2 or 4, tabs, printWidth 80 / 100 / 120Validate then format: a practical workflow
Open the GraphQL validator, paste a single schema document (max 512 KiB UTF-8), and wait for the debounced verdict. The results panel shows Valid or Invalid, the first error with line and column when known, a copy-error action, and schema stats when parse succeeds.
The GraphQL beautifier pretty-prints schemas and operations with Prettier. Use it for review diffs — it does not replace validate. Options: 2 or 4 spaces or tabs, plus print width. Browse all formatters on the beautify tools hub.
A teammate renamed Pet to Animal but left pet(id: ID!): Pet on Query. CI or the server fails with little context in the GitHub overlay.
Step 1: Paste the schema into validate-graphql
Open validate-graphql. An invalid verdict with Unknown type "Pet" (and a line when available) points at the stale field.
Step 2: Fix the type name or restore the type
Either rename the field return type to Animal or add type Pet back. Re-paste until the panel shows a valid schema.
Step 3: Beautify and commit
Run the fixed SDL through beautify-graphql, download or copy, and update the PR. Reviewers read types, not a one-line blob.
A generated or minified-looking schema lands in the repo. Reviewers cannot see which fields sit on Query versus Mutation.
Step 1: Beautify first if you cannot even read it
Paste into beautify-graphql. Prettier unwraps nested selections and type bodies. This step does not prove the schema is valid.
Step 2: Validate the formatted document
Copy the pretty SDL into validate-graphql. Confirm the Query root exists and that every named type is defined.
Step 3: Check the stats tiles
Type count and root-field counts help you spot an empty Query or a schema that accidentally dropped mutations. Then commit the formatted file.
Conclusion
Validate GraphQL SDL in the browser with buildSchema, then format with Prettier — locally, without sending the schema anywhere. That loop catches unknown types and missing Query roots before CI or a gateway. It does not replace a running server, introspection, or federation compose. For REST contracts, stay on the API hub; for readable queries, stay on Beautify GraphQL.
Related Articles

Lower your OpenAI/Anthropic/Gemini bill: estimate input/output, model batch and caching in your calculations — verified rates, 100% local.

RAG, multi-turn agents, system prompts: calculate context-window usage and remaining headroom before calling the API.

Honest guide: uniform tabular data, convert → count → price → context workflow; not a JSON/YAML replacement manifesto.