DevTools Hub

Search tools

Search for a developer tool

GraphQL

GraphQL Formatter

Format a GraphQL query, mutation, or SDL schema with consistent indentation, using the real GraphQL reference parser.

Part of the GraphQL Toolkit
Formatted
1 operation

What this does

Paste a query, mutation, subscription, fragment, or an SDL schema (type, interface, input, and the rest), and it's parsed with graphql-js, the GraphQL Foundation's own reference implementation, then re-printed with that same library's AST printer. This isn't a hand-rolled formatter guessing at indentation — because the input has to parse as a real, valid GraphQL document first, the output is guaranteed to be syntactically valid GraphQL, and a genuine syntax error gets reported with the exact line and column instead of a best-effort reformat.

What gets stripped, and what doesn't

Verified directly against the parser: a #-style comment is not preserved — graphql-js never attaches comments to the parsed document at all, so a heavily-commented query comes back with every # line gone. A """block string""" description in an SDL schema is a completely different thing and is preserved, since descriptions are a real part of the AST, not a stripped-out comment. The two look similar at a glance but behave nothing alike here.

FAQ

Is my query or schema uploaded anywhere?

No — parsing and formatting happen entirely in your browser.

Does this validate my query against a real schema?

No — this only checks that the document is syntactically valid GraphQL, the same way a formatter checks that JSON parses without knowing what a specific API expects. It has no concept of your schema's actual types, fields, or arguments. For that, see GraphQL Query Validator.