GraphQL Minifier
Strip comments, descriptions, and whitespace from a GraphQL schema to ship the smallest possible SDL
Input
Output
Paste your input on the left and the result shows up here.
Or drop a file on this box, , or .
What is the GraphQL Minifier?
When you ship a GraphQL schema as part of a deploy artifact, a Lambda bundle, or a CDN-delivered SDL string, the descriptions and `#` comments add up fast. A real production schema can easily be 40-60% documentation by byte count: useful when humans are reading it, dead weight when it is going over the wire to bootstrap a client. The GraphQL specification defines comments, block-string descriptions, and most whitespace as ignored tokens, which means any reasonable parser ignores them anyway. This minifier strips all of that and returns a single-line SDL that is byte-for-byte equivalent to the original from the parser's perspective.
No graphql package ships with this page; it has its own small tokenizer. That tokenizer throws away # comment tokens and """ block-string tokens, keeps everything else, and joins the rest back together with a space only where two words would otherwise run into each other, as in type Pallet. Short descriptions written in plain double quotes are ordinary string tokens, so those stay. Before printing, it checks that every {, ( and [ has a partner and names the line if one does not. That is a balance check rather than a full parse, so load the result once in graphql-js or Apollo Server before you ship it.
The minifying happens on this page, in your own browser tab. Your schema is not sent off or saved anywhere. Paste, minify, copy.
How to Use the GraphQL Minifier
There is no Minify button, because the output refreshes whenever the input changes. What is left for you is loading the SDL and carrying the single line away.
Paste, Upload, or Load a Sample
Paste a schema into Input. Give it a third of a second after your final keystroke and the one-line result shows up on the right, while the pill beside the Output heading shows how many bytes went and what share of the file that was. Upload opens .graphql, .graphqls, .gql or .txt files up to 5 MB, and Sample loads a heavily documented storefront schema so the saving is easy to see. Take a warehouse type like this one:
"""A pallet scanned at the loading dock."""
type Pallet {
# barcode printed on the shrink wrap
code: String!
weightKg: Float!
scannedAt: DateTime!
} The comment and the """ block above Pallet both disappear, and what comes out is type Pallet{code:String!weightKg:Float!scannedAt:DateTime!}. No space is needed after ! or :, which is why the line gets so short, and it is still a valid type in the GraphQL schema language.
Read the Minified Output
The right Output panel renders the minified SDL on a single line, with the saved-bytes pill in the panel header so you can see at a glance how much you saved. Comments (# ...) and block-string descriptions ("""...""") are stripped completely: they do not change how a query executes, and any introspection-based tooling will pick up descriptions from your resolver layer anyway. If the SDL has unbalanced braces or any other parse error, the minifier surfaces a friendly inline message: it never throws or crashes.
Copy or Download
Copy gives you the single line for a deploy script, an environment variable or a config value; Download saves it as schema.min.graphql. If the input had a brace problem, Download refuses instead of saving the error text. Clear resets the Input pane, and none of this leaves the page.
When You'd Actually Use This
Smaller Deploy Artifacts
Bundling your schema into a serverless function or a Docker layer? Stripping descriptions and comments typically halves the byte count. Multiply that by every cold start and every layer download and the savings show up on your bill. The runtime parser does not care: descriptions are introspection-only metadata, and most production deploys turn introspection off anyway per Apollo Router's production guidance.
CDN-Delivered Schemas
If your gateway fetches the SDL from a CDN at boot (Federation supergraph composition, schema registry pulls), every byte costs latency on the cold path. Minified SDL parses identically and shaves a chunk off the wire size, often more than gzip would, because gzip cannot compress what is already removed.
Inlining Schemas in Source
Sometimes you need to inline a schema string in a config file, an env var, or a hand-written tool. A minified single-line version drops cleanly into a TypeScript template literal or a YAML scalar without escaping every newline.
Diff Noise Reduction
When two revisions of a schema only differ in descriptions or comments, the actual structural diff is buried under doc-string changes. Minifying both sides before diffing isolates the real schema delta, which is useful for change-management and breaking-change detection.
Common Questions
Is the minified schema still valid GraphQL?
Yes. Every token the spec defines as ignorable (comments, descriptions, redundant whitespace, commas) is removed, but every name, punctuator, string literal, and number is kept. The output parses to the exact same AST as the input. You can verify this by running both through graphql-js and comparing the resulting documents.
Will I lose my schema documentation?
Yes. That is the point. Descriptions and `#` comments are stripped. Keep your unminified source in version control and only minify when you are about to ship the artifact. Documentation that you actually want surfaced to clients lives in your introspection response, which is generated from your runtime resolver metadata, not from the deployed SDL string.
Is my schema sent to a server?
No. The stripping is done by JavaScript in this tab, so the schema never travels to us and nothing gets logged. Paste internal or unreleased schemas without worrying.
How much can I expect to save?
It depends on how heavily documented your schema is. A bare-bones SDL with no descriptions saves 10-15% (just whitespace). A well-documented schema with block-string descriptions on every type and field typically saves 40-60%. The saved-bytes pill in the output panel header tells you the exact number for your input.
Does it handle directives, custom scalars, and federation?
Yes. @deprecated, @key, @external, scalar DateTime, and any custom directive or scalar are kept. The minifier only strips ignorable tokens: anything semantic stays. Federation directives round-trip cleanly.
How big a schema can I minify?
Up to 5 MB of input. Past that the page says the input is too large rather than locking up the tab. Real schemas are almost always far below the cap, so the limit you are more likely to notice is the editor scrolling through a very long file.
Other GraphQL Tools
If you need the readable version back, or you are trimming other files in the same deploy bundle, these are the next stops: