ToolLineup

GraphQL Formatter

This GraphQL formatter parses and reprints queries, mutations, fragments and schema definitions: one field per line, selection sets indented consistently, and normalised spacing in argument lists and variable definitions. Because the document is parsed before it is printed, an unbalanced brace or a stray comma is reported with its position rather than being silently reformatted into something that looks fine but no longer means what you wrote. Everything runs in your browser.

How it works

Formats queries, mutations, fragments and schema definitions: one field per line, consistent indentation for selection sets, and normalised spacing in argument lists.

The document is parsed first, so a malformed query is reported with its position rather than silently reformatted into something else.

Everything runs in your browser — nothing you paste is sent to a server.

GraphQL input
Paste GraphQL here…
Formatted GraphQL

How to format GraphQL

  1. Paste a query, mutation, fragment or schema into the input on the left.
  2. Choose an indent size and wrap width.
  3. Copy or download the formatted document.

What formatting does

  • One field per line, with selection sets indented consistently.
  • Normalised spacing in argument lists and variable definitions.
  • Consistent layout for fragments, directives and schema type definitions.

Malformed documents are reported

The document is parsed before it is printed, so an unbalanced brace or a stray comma is reported with its position rather than being silently reformatted into something that looks fine but no longer means what you wrote.

Common use cases

  • Tidying a query copied out of a network inspector.
  • Making a long schema definition reviewable.
  • Normalising queries stored as strings in application code.

Frequently asked questions

What can it format?

Queries, mutations, subscriptions, fragments, and schema definition language — type, input, enum, interface and union definitions all format correctly.

What happens with a malformed query?

It is reported with its position. The document has to parse before it can be printed, so the formatter effectively finds the error for you rather than reformatting around it.

Are comments and descriptions kept?

Yes. Hash comments and triple-quoted schema descriptions are both preserved.

Can I format a query stored as a string in my code?

Yes — paste just the query text. Formatting the surrounding JavaScript is a separate step with the JavaScript formatter.

Is my code uploaded anywhere?

No. Everything runs entirely in your browser, so nothing you paste is transmitted or stored on a server.

Related tools