Developer Tools
GraphQL Formatter
Format, beautify, minify, and validate GraphQL queries, mutations, fragments, and schemas in your browser. Built-in tokenizer, no signup, no upload.
Your query is parsed and printed in the browser using a built-in tokenizer. The text you paste is never uploaded.
What the formatter handles
- Operations: query, mutation, subscription, anonymous shorthand { ... }.
- Fragments: fragment definitions, fragment spreads, and inline fragments (with or without type conditions and directives).
- Variables and arguments: $vars, default values, list and object literals, enum values, and block strings as argument values.
- Directives: @include, @skip, @deprecated, @cacheControl, and any custom @name(args) directives.
- Type system: type, interface, union, enum, input, scalar, schema, directive, and extend definitions are tokenized and re-emitted with the same indentation rules as operations.
- Comments and descriptions: # comments stay on their own line; """block string""" descriptions are reindented to match the surrounding depth.
How to use
- Paste a GraphQL document (query, mutation, subscription, fragment, or full SDL schema) into the input area.
- Pick a mode. Format pretty-prints with one selection per line; Minify produces a single-line transport form; Validate runs the tokenizer and bracket-balance check without changing the output.
- In Format mode, choose 2 or 4 spaces of indent to match your codebase style.
- Use Load sample query or Load minified sample to see the formatter expand a compact query, or Clear input to start fresh.
- Click Copy on the output panel to copy the formatted, minified, or validated text. Errors include the line and column so you can fix them quickly.
About this tool
GraphQL Formatter is a browser-based pretty-printer, minifier, and validator for GraphQL documents. Paste a query, mutation, subscription, fragment, or full SDL schema and the tool tokenizes the source against the GraphQL specification's lexical grammar, then re-emits the tokens with consistent indentation, single spaces between identifiers, no trailing commas, and one blank line between top-level definitions. The format mode produces output that matches the conventions used by graphql-js prettyPrint and the Prettier GraphQL plugin: selection sets open at the end of the parent line, each field or fragment spread sits on its own line indented by 2 or 4 spaces (your choice), argument lists wrap when there are two or more arguments or when an argument value is itself multi-line, object and list literals expand the same way, and triple-quoted block string descriptions are re-indented so they align with their surrounding scope. The minify mode strips every non-significant whitespace character, joins the document onto a single line, drops line comments (because they end at a newline and would be lost anyway), and inserts the minimum spacing required to keep adjacent Name, Int, and Float tokens from merging into one token, producing the compact form most often used for HTTP transport. The validate mode runs the same tokenizer and a single-pass bracket balance check; it reports the first unterminated block string, unterminated string literal, unexpected character, leading zero, or mismatched bracket along with the source line and column so you can jump straight to the issue. The tokenizer covers names, variables ($name), directives (@name), Int and Float literals (including exponent and sign rules), single-quoted strings with escape sequences and the Unicode escape forms \uXXXX and \u{X+}, block strings with triple quotes and the spec-compliant \""" escape, ellipsis spreads, and every single-character punctuator (! $ & ( ) : = @ [ ] { | } and the insignificant comma). Operation keywords (query, mutation, subscription), fragment, on, the type system keywords (type, interface, union, enum, input, scalar, schema, directive, extend, implements, repeatable), and the literals true, false, null are lexed as Names because GraphQL is keyword-light by design. Everything runs in your browser; the query or schema you paste here is never uploaded to a server.
Free to use. Works in your browser. No signup, no login.
Related tools
You may also like
JSON Formatter
Format, minify, and validate JSON in your browser.
Open tool
DeveloperJSON Minifier
Compact JSON with live byte savings and a JS literal copy.
Open tool
DeveloperSQL Formatter
Pretty print SQL with configurable keyword case, indent, and comma style.
Open tool
DeveloperYAML Formatter
Pretty print and validate YAML with consistent indent, sorted keys, and clear errors.
Open tool
DeveloperXML Formatter
Format, minify, and validate XML with line and column error reporting.
Open tool