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.

Frequently asked questions

Does it format schemas as well as queries?

Yes — queries, mutations, subscriptions, and SDL schema definitions.

Can it minify too?

Yes — Minify strips newlines and redundant whitespace for transit.

How does it differ from the GraphQL prettifier?

They overlap; this one also minifies, while the GraphQL prettifier focuses on expanding to readable form with adjustable indent width.

Can I convert a schema to TypeScript?

Use the GraphQL to TypeScript converter for types from an SDL schema.
Embed this tool on your site

Free to embed, no attribution required (but appreciated). Paste this where you want the tool to appear: