GraphQL Query Formatter
Format GraphQL queries, mutations, subscriptions, and SDL (Schema Definition Language) into readable indented output. Handles fragments, inline fragments, directives, and variable definitions.
How to use the GraphQL Query Formatter
Paste a GraphQL query, mutation, or SDL schema. Format produces canonical formatting (Apollo / Relay style); Minify strips newlines and unnecessary whitespace.
Formatting GraphQL documents
GraphQL queries, mutations, and SDL schemas arrive in inconsistent shapes — minified for network transit, hand-written with erratic indentation, or pasted from a log with everything on one line. Fragments, inline fragments, directives, and variable definitions each have their own nesting, and reading a deeply selected query without consistent indentation is genuinely hard.
This formats a GraphQL document into canonical, evenly indented output (Apollo/Relay style), or minifies it back to a single line for transit. It handles both queries and schema SDL; for a prettify-only pass with finer indent control, the GraphQL prettifier is a close sibling, and to turn a schema into other shapes see the GraphQL to TypeScript and GraphQL to JSON Schema converters.
Common use cases
- Read a query — indent a minified or messy query to inspect it.
- Shrink for transit — minify a query to send over the wire.
- Schema review — format an SDL schema for a readable diff.
- Consistent style — normalise team queries to one canonical layout.
- Debugging — expand a logged single-line operation.