GraphQL Developer Tool

GraphQL Query Formatter

Paste any GraphQL query, mutation, subscription, or fragment and pretty-print it with consistent indentation — or minify it to a single line.

Operations
Fields
Indent preset
2 spaces

GraphQL source

Queries, mutations, subscriptions, and fragments are all supported.

Format controls

Formatted output

Client-side only. Nothing leaves your browser.

About GraphQL Query Formatter

GraphQL Query Formatter turns a flat or messy GraphQL document — pasted from a network request, log line, IDE, or chat thread — into a clean, indented, easy-to-read structure. It parses your full document (operations and fragments) and prints it back with consistent spacing, aligned arguments, and one selection per line.

The tool understands the entire GraphQL query language: named and anonymous operations, variable definitions with default values and directives, fragment spreads, inline fragments with type conditions, aliases, list and object arguments, enum values, block strings, and nested selection sets. Whether you have a single field shorthand { me { id } } or a 200-line multi-operation document, it formats both with the same rules.

Everything runs entirely in your browser. Your GraphQL is never sent to any server, which makes it safe for use with internal schemas, private fields, and proprietary mutations.

How to Use GraphQL Query Formatter

  1. 1. Paste your GraphQL document. Drop in a single query, a minified mutation, a subscription, or a file containing multiple operations and fragments. The tool accepts any valid GraphQL Query Language (executable definitions).
  2. 2. Pick an indent style. Choose between 2 spaces, 4 spaces, or tabs. Most teams prefer 2 spaces for compactness; pick tabs if your editor is configured for them.
  3. 3. Click Beautify. The parser validates the document and prints it back with each field on its own line, aliases preserved, arguments spaced as name: value, and directives kept inline with their target.
  4. 4. Or click Minify. Strip every newline and unnecessary space to get a single-line version suited for embedding inside JSON request bodies, environment variables, or shell scripts.
  5. 5. Copy or download. Use the Copy button for quick paste, or Download to save a .graphql file you can commit to your repo or open in any GraphQL-aware editor.

Common Use Cases

Debug captured requests

Paste the minified query string from a network panel or server log to read what your client is actually sending.

Clean up persisted queries

Reformat queries pulled out of persisted-query stores or hash maps before reviewing or committing them to source control.

Compose Apollo / Relay snippets

Standardize GraphQL strings inside gql template literals so diffs stay small and PR reviewers can scan them.

Embed in JSON payloads

Minify a multi-line query into a single line so it fits neatly inside a JSON request body for curl, Postman, or shell scripts.

Validate syntax on the fly

The parser catches unterminated strings, missing brackets, stray punctuation, and unexpected keywords with a clear error message.

Document API examples

Produce consistently formatted snippets for README files, internal wikis, and customer-facing API documentation.

FAQ

Does this tool send my query to a server?

No. The formatter is 100% client-side. Your GraphQL never leaves your browser, so it is safe to use with private schemas and internal-only operations.

Does it support mutations, subscriptions, and fragments?

Yes. The parser handles every executable definition: query, mutation, subscription, named fragments, and inline fragments with type conditions. Multiple definitions in a single document are formatted together with a blank line between them.

Will it preserve aliases, arguments, and directives?

Yes. Aliases are emitted as alias: field, arguments are spaced as name: value separated by commas, and directives stay attached to the field, fragment, or operation they target with their own argument lists intact.

What about comments?

GraphQL comments (lines starting with #) are treated like whitespace by the GraphQL spec and are stripped during formatting. Move any explanatory text to your source code or schema instead of the executable document.

How do I format only the variables JSON?

Use the companion GraphQL Variables Formatter. It is built specifically for the variables object or full request body JSON that accompanies a GraphQL query.

Can I minify a query for embedding inside JSON?

Yes. Click the Minify button to collapse the document onto a single line with single-space separators. The output is valid GraphQL ready to be JSON-encoded as a string value.

What does the error message mean?

The parser reports the first unexpected token it sees, for example Expected punct "}", got name "foo". Look near the end of the partially valid prefix to find the typo — usually a missing brace, a stray comma, or a misspelled keyword.