GraphQL Query Formatter

Paste a GraphQL query or mutation and it is reformatted as you go.

How it works

This is a brace-depth pretty-printer, not a real GraphQL parser. It tracks { and } to indent by 2 spaces per nesting level, puts each field or argument-block on its own line, and keeps a parenthesized argument list's internal spaces — user(id: $id, name: $name) — from being split across lines. Quoted strings, both "..." and triple-quoted """...""" block strings, are scanned wholesale and never reformatted internally, and a # comment runs to end of line and is emitted verbatim on its own line. A mismatched brace count produces a clear error rather than a broken result.

Frequently asked questions

Does this validate my query, the way a real GraphQL tool would?

No — it is a brace-depth-based pretty-printer, not a full GraphQL parser or validator. It will not catch semantic errors like referencing a field that does not exist on the schema, an undefined variable, or a type mismatch. It only reformats the syntax you already have; a query that runs fine against your server will format the same as one that would fail there.

How are triple-quoted block strings (""" ... """) handled?

Left completely untouched, embedded newlines included. Reformatting inside a deliberately-preserved multi-line string block — re-indenting its interior lines, for instance — would corrupt the text it is meant to carry verbatim, so it is scanned as one opaque token and passed through exactly as written.

What does an "unbalanced braces" error mean?

It means the pasted query has a missing or extra { or } somewhere — the count of opening and closing braces does not match. Since this tool tracks brace depth to figure out indentation, it cannot produce a sensible result until that is fixed.