DEVELOPER & DATA

GraphQL Formatter

Pretty-print or minify a GraphQL query, mutation, fragment or SDL document, with the operations, fields and maximum selection depth counted as it goes.

The formatted or minified document to copy or download, the operations, fragments and type definitions it holds, the field count, the maximum selection depth, and the bytes saved.

Example: An 83-byte query with one variable formats to 110 bytes over eight lines and minifies to 71 — 14.5 % smaller — with 5 fields at a maximum selection depth of 3.

v0.1.0 · last reviewed 22 September 2026
Loading the workspace…
BUILT TO BE UNDERSTOOD

Layout only,
and nothing else.

What the tokeniser understands, what the counts are for, and the line this page does not cross.

The tokeniser

Formatting runs on an in-house tokeniser rather than a schema-aware parser: it understands names, numbers, strings and block strings, comments, the punctuators GraphQL uses, and the fact that commas are insignificant whitespace — which is why minifying can drop them and leave a valid document. Unbalanced brackets, an unterminated string or a stray character are reported at a line and column instead of producing mangled output. Queries, mutations, subscriptions, fragments and SDL type definitions all go through the same path.

What gets counted

Alongside the formatted text the page reports the operations, fragments and type definitions in the document, the field count, the number of variable references and directives, and the maximum selection depth. Depth is the one worth watching: it is the limit most public APIs enforce, because a deeply nested selection is the classic way to make a server do far too much work for one request. The byte counts show what minifying actually buys, which for a short query is often less than it looks.

Limits

This is layout, not validation. Nothing is checked against a schema, no field is reordered or removed, no query is executed and no request is sent anywhere — there is no endpoint field on this page for exactly that reason. Comments are kept by default when pretty-printing and always removed when minifying, since they carry no meaning to a server. Documents up to two megabytes are handled. Nothing leaves the browser; the same four anonymous usage counts as the rest of the site apply.

SOURCES

  • In-house tokeniser: block strings, comments, insignificant commas and the GraphQL punctuators; layout only — nothing is validated against a schema, reordered, executed or sent anywhere

Last reviewed 22 September 2026. How results are checked: How we verify.