Formatted or minified GraphQL will appear here.

Free Online GraphQL Formatter

Paste a GraphQL query, mutation, subscription, or fragment to reformat it with consistent two-space indentation, or collapse it to a single compact line for embedding in code. It helps API developers read queries, mutations, and fragments consistently while debugging a GraphQL request.

Why format GraphQL queries?

GraphQL queries built by hand, copied from browser devtools network tabs, or generated by tooling often arrive as a single dense line or with inconsistent indentation. A consistently formatted query is far easier to review in a pull request, paste into documentation, or debug when something in a nested selection set isn't returning what you expect. This tool parses the query as real GraphQL syntax — not just guessing at brace positions — so the structure it prints back out is guaranteed to match what a GraphQL server would actually parse.

How to use this formatter

Paste any GraphQL document — a query, mutation, subscription, or a standalone fragment definition — into the box and click Format to get readable, indented output, or Minify to collapse it to a single compact line suitable for embedding in a config file or a URL parameter. Variable definitions, directives like @include and @skip, inline fragments, and nested selection sets are all handled and re-indented correctly.

Common use cases

  • Cleaning up a GraphQL query copied from a browser's network inspector before adding it to your codebase
  • Reviewing a large, deeply nested query in a pull request where indentation matters for readability
  • Minifying a query before sending it as a URL query-string parameter for a GET-based GraphQL request
  • Formatting a fragment definition shared across multiple queries so it's easy to read on its own

Everything runs locally in your browser using a small hand-written GraphQL parser — nothing you paste is ever uploaded to a server.

How to use GraphQL Query Formatter for related tasks

Paste a GraphQL operation, format the query, and review nesting, arguments, variables, and fragments before sending it to a server.

Related tools: REST API Tester, JSON Beautifier.

Frequently asked questions

What kinds of GraphQL documents can this formatter handle?

Queries, mutations, subscriptions (including the shorthand form with no operation keyword), fragment definitions, inline fragments, variable definitions with default values, directives, and all standard argument/value types (strings, numbers, booleans, enums, lists, and objects).

Does this validate my GraphQL against a schema?

No — this only checks that the document is syntactically valid GraphQL and re-prints it with consistent indentation. It doesn't know your schema, so it can't catch things like an unknown field or a wrong argument type; a real GraphQL client or server will still validate that when the query runs.

What happens to comments in my query?

Comments (lines starting with #) are preserved and re-emitted directly above the field or definition they were attached to in the formatted output.

Is my GraphQL query uploaded anywhere?

No. Parsing and formatting run entirely in your browser using a small hand-written GraphQL tokenizer and parser — nothing you paste is sent to a server.

How do I make a GraphQL query readable?

Paste the operation and format it; indentation makes nested selections and mutation arguments easier to inspect, but schema validation still belongs to the API.