GraphQL formatter
Processed in your browser · nothing is uploaded
Indents a GraphQL query, mutation or schema by nesting depth, keeps arguments on the field they belong to, and drops the optional commas nobody writes.
How to use the graphql formatter
GraphQL has no formal formatting rules, so the convention is just what every tool converged on: two spaces per level, the opening brace at the end of the line it belongs to, one field per line. Commas between fields are legal and optional — the grammar treats them as insignificant, like whitespace — and removing them is the convention because they add nothing. Aliases and directives stay attached to their field here, which is the part a naive line-splitter breaks. `short: reallyLongFieldName` is one selection with an alias, and `field @include(if: $x)` is one selection with a directive; splitting either on whitespace produces something that no longer parses. Minifying a query is genuinely useful in one place: a persisted-query hash. If the client and server hash the query text, both must normalise it the same way or the hashes never match — which is a real deployment failure and the reason a minifier exists at all.
Questions
No. They are insignificant, like whitespace, and the convention is to leave them out.