GraphQL formatter
Format or minify a GraphQL query, mutation, fragment or schema with consistent indentation.
GraphQL formatter
Paste a GraphQL query, mutation, fragment or schema and this tool reformats it with consistent, readable indentation — or minifies it to a single line for shipping over the wire. It understands the structure shared by operations and type definitions, so a query with nested selection sets and a schema full of type blocks both come out cleanly indented, with fields, arguments, directives and variable definitions in the right place.
Choose the indent width (2 spaces, 4 spaces or a tab), or turn on "Minify instead of format" to strip whitespace and comments down to the shortest valid document. "Sort fields alphabetically" reorders the fields inside each selection set or type block, useful for spotting a missing or duplicated field in a long query. "Collapse query variables to one line" decides whether an operation's `$variable: Type` list stays on one line or breaks onto its own indented line per variable, and "Blank line between operations" adds spacing when the input has more than one query, mutation or fragment.
The tool also checks as it formats: unmatched or unclosed brackets are reported instead of guessed at, and a selection set that spreads a fragment (`...MyFragment`) with no matching definition in the pasted text gets its line flagged. The live tally reports how many definitions were found and how deeply the query nests — an early-warning sign for an over-fetching query.
Formatting runs entirely in your browser — nothing you paste is uploaded, which matters for schemas and queries that reference internal field or type names. Copy the result, download it as a .txt file, or send the output back into the input to apply another pass with different options.