TOOLTIKI Lovable tool, really free
Developer Formatting

GraphQL formatter

What to do
Indent

Processed in your browser · nothing is uploaded

Local · aliases and directives stay attached
Advertisement
320 × 100

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

1 Paste your input. The result appears immediately.
2 Pick the operation you want.
3 Copy the result, or save it as a file.

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.

GraphQL specification — languageGraphQL — insignificant commas
Advertisement
300 × 250
Was this tool any good?
INTERNAL SIGNAL ONLY · WE USE IT TO FIND TOOLS WORTH REBUILDING