GraphQL SDL: Validate and Format a Schema Online

GraphQL SDL: Validate and Format a Schema Online

SDL syntax errors, schema review and formatting before merge — extends the existing GraphQL beautifier.

25.08.2026
8 min read
Share this article:
GraphQLSDLSchemaValidateAPITutorial

Validate GraphQL SDL before the merge

A schema that does not parse blocks code generation, stops the GraphQL server from starting, 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 buildSchema from GraphQL.js in your browser. Paste the schema document, and you get a valid or invalid verdict, with line and column when GraphQL.js provides them. Formatting stays on Beautify GraphQL (Prettier), and 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.

Catch SDL syntax errors and unknown types before CI or server boot
Line and column on errors when GraphQL.js reports a location
Schema statistics: type count, Query / Mutation / Subscription fields
100% in the browser: your schema is never uploaded
Format queries and SDL separately with Beautify GraphQL (Prettier)

Honest limits and habits that survive code review

What validate-graphql does not do

A valid verdict means buildSchema from GraphQL.js accepted the pasted SDL. It is not a proof that your API behaves correctly in production.

No query or mutation execution: no resolver calls and no variable coercion against live data
No introspection of a running server, so paste the schema document you own
No retrieval of remote .graphql files, includes, or Git URLs
No GraphQL Federation or supergraph composition: one SDL document per paste
512 KiB UTF-8 maximum on the validator, so huge monoliths need local tooling
Single file, local check, then CI

The 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.

Keep one schema file (or a bundled SDL) so the paste matches what CI sees
Do not treat FastMinify as a billing or uptime monitor for your GraphQL endpoint
Document whether the repo uses a default Query type or a custom schema { query: … }
If you also ship OpenAPI, validate that contract separately; see the OpenAPI guide
For JSON Schema instances, use json-schema-validator, which works on a different metamodel
Review habits that catch real breakage

Most SDL incidents are rename leftovers and missing roots, not exotic GraphQL features.

After every type rename, paste the full schema, because the changed lines alone hide the leftovers
Require a Query root (or an explicit schema definition) in the same PR as new types
Beautify before asking for review, so field lists are visible in the GitHub diff
Copy the validator error into the PR description when CI logs are noisy
Keep the formatting options (2 or 4 spaces) aligned with the repo's Prettier config

Schema SDL and queries are two documents with two tools

What GraphQL SDL actually is

Schema Definition Language (SDL) describes types, fields, and roots. It is the contract your resolvers must meet, not an executable query. FastMinify validates that contract with buildSchema from GraphQL.js, without talking to a live server.

Object types, interfaces, enums, unions, scalars, and input objects
Root fields on Query, Mutation, and Subscription when those types exist
The results panel counts those types and root fields after the schema parses
SDL is a document you paste, and FastMinify does not fetch .graphql files from a URL
A valid verdict means GraphQL.js accepted the schema document, not that your production resolvers match it
Queries, mutations and fragments do not belong here

An operation document (query, mutation, subscription, fragment) is not schema SDL. Pasting one into the validator fails buildSchema. Format those documents on Beautify GraphQL instead.

Validate GraphQL accepts schema SDL only: buildSchema, no query execution
Beautify GraphQL formats both schema SDL and operation documents with the Prettier GraphQL parser
Codegen and Apollo/Yoga still need a valid schema; pretty-printing a query will not fix an unknown type
FastMinify has no GraphQL query runner and no live introspection
For JSON payload checks on a REST API, use the JSON validator, which does not understand SDL
The Query root is usually required

GraphQL.js typically requires a Query root type unless your schema definition names another query type. A document with only type User { … } and no query root usually fails validation, which is expected and not a FastMinify bug.

Minimal valid paste: type Query { hello: String }
Custom root: schema { query: RootQuery } plus type RootQuery { … }
A missing Query is one of the most common “it works in my editor” surprises
Undefined types fail with a message such as Unknown type "Foo", often with a line number
Some semantic errors omit locations, and the verdict is still invalid
Validate and beautify are not interchangeable

Validation answers "is this schema SDL accepted by GraphQL.js?". Beautify answers "is this GraphQL readable?". Indentation never fixes an unknown type.

Validate runs buildSchema and returns valid or invalid, with line and column when available
Beautify uses Prettier with tabWidth 2 or 4, tabs, and printWidth 80 / 100 / 120
The JavaScript Prettier options (semicolons, quotes, trailing commas) do not apply to GraphQL
Recommended order: validate the SDL → fix the types → beautify → open the PR
Beautify can format a query that validate-graphql will rightly reject as non-SDL

Validate first, then format

Using the GraphQL SDL validator

Open the GraphQL validator, paste a single schema document (max 512 KiB UTF-8), and wait for the verdict, which appears after a short debounce. The results panel shows Valid or Invalid and the first error with line and column when known. It also has a button to copy the error and, when the schema parses, schema statistics.

Paste schema SDL only, not a query and not a remote endpoint URL
Validation runs in the editor as you type, with no upload and no account
Statistics once the schema parses: types, Query fields, mutations, subscriptions
Copy the error message into the PR when you want a written record
The cap is 512 KiB, so larger schemas belong in local GraphQL.js or CI
Format with Beautify GraphQL

The GraphQL beautifier pretty-prints schemas and operations with Prettier. Use it for review diffs; it does not replace validation. Options: 2 or 4 spaces or tabs, plus print width. Browse all formatters on the beautify tools hub.

SDL that people can read, with nested fields unwrapped
Same Prettier engine as the rest of the FastMinify formatter family
Syntax errors come with a line hint, so fix and retry
Queries and fragments are welcome here; they are not welcome on validate-graphql
Chain validate → beautify, so reviewers see a typed, indented schema
An unknown type in a pull request

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 view.

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.

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.

3

Beautify and commit

Run the fixed SDL through beautify-graphql, download or copy it, and update the PR. Reviewers read types, not a one-line blob.

Unreadable SDL before a schema review

A generated or minified-looking schema lands in the repo. Reviewers cannot see which fields sit on Query and which on Mutation.

1

Beautify first if you cannot even read it

Paste it into beautify-graphql. Prettier unwraps nested selections and type bodies. This step does not prove the schema is valid.

2

Validate the formatted document

Copy the pretty SDL into validate-graphql. Confirm the Query root exists and that every named type is defined.

3

Check the statistics 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 it with Prettier, all locally and 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 composition. For REST contracts, stay on the API hub, and for readable queries, stay on Beautify GraphQL.

Paste schema SDL into validate-graphql before every schema PR
Do not paste queries into the validator; format them on Beautify GraphQL
Expect a Query root unless your schema definition names another type
Treat a valid verdict as GraphQL.js acceptance, not production proof
Chain validate → beautify, then keep CI as the merge gate
Share this article
Share this article: