Input

Output

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.

The minifier is hand-rolled — no graphql npm package is loaded into the page, so first paint stays small. It tokenises the SDL, drops every comment and block-string token, and re-emits the structural tokens with the absolute minimum whitespace required to keep adjacent name tokens distinct (the only place spec-compliant SDL actually needs a space). The output is verified by the same lightweight parser used in the formatter, so the round-trip through graphql-js or Apollo Server at startup behaves identically to the original.

Everything runs in your browser. No upload, no schema stored anywhere. Paste, minify, copy.

How to Use the GraphQL Minifier

Three quick steps. The buttons described below are the actual buttons on this page — there is no Minify button because minification runs automatically.

1

Paste, Upload, or Load a Sample

Paste a GraphQL schema into the left Input panel — minification happens automatically a fraction of a second after you stop typing, so there is no Convert button to hunt for. Click Upload for a .graphql, .graphqls, or .gql file, or hit Sample to load a realistic e-commerce Order schema with comments and block-string descriptions you can watch get stripped. A typical input looks like this:

"""An order placed by a customer."""
type Order {
  # The unique order identifier
  id: ID!
  placedAt: DateTime!
  customer: Customer!
  items: [OrderItem!]!
  status: OrderStatus!
}

Both server-style schemas (with extend type Query) and standalone type definitions work. The shapes accepted match what the GraphQL schema definition language supports.

2

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 have zero semantic meaning per the Relay GraphQL specification, 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.

3

Copy or Download

Hit Copy to grab the minified schema for inlining into a deploy script, a Lambda env var, or a config file. Hit Download to save as .graphql. The clear button on the input panel resets you to a blank state. Minification happens entirely client-side — your schema never 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. Minification runs entirely in your browser. Nothing is uploaded, nothing is logged. Safe to paste internal or unreleased schemas.

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?

Anything your browser comfortably renders. Schemas of a few hundred types are no problem. Past around 5 MB the Ace editor itself starts to slow down — that is the bottleneck, not the minifier.

Other GraphQL Tools

Minifying is one part of working with GraphQL. These tools handle the rest: