GraphQL Formatter

Indent queries, mutations and SDL, keeping arguments, strings and comments intact.

Indent
GraphQL

Arguments stay on their field's line, strings and comments are protected, and a comment never shares a line with code.

Formatted

How to Format GraphQL

1

Paste your operation

A query, a mutation, a fragment or a chunk of schema definition language. Everything collapsed onto one line, which is how queries usually arrive from a log, is exactly the case this handles.

2

Choose the indentation

Two spaces is the community convention and four is available if your project prefers it. Selection sets are indented by nesting depth either way.

3

Copy the result

Arguments stay with their field, aliases and spreads stay on one line, and descriptions and comments get their own lines so nothing is accidentally commented out.

Features

Queries, mutations, fragments and schema definition language
Arguments kept on the same line as their field
Aliases, spreads and inline fragments kept intact
Directives stay attached to the field they modify
Strings protected, so a brace inside one never shifts indentation
Comments and block descriptions placed on their own lines
Two or four space indentation
Free, browser based, no sign-up

Frequently Asked Questions

No, it formats. Layout is corrected but syntax is not checked against a schema, so an invalid query will still be laid out neatly. Use your API's tooling for validation.

No. Strings, block strings and comments are captured before any layout work happens, so a brace inside a default value or a description is never treated as structure.

Because a GraphQL comment runs to the end of the line. If it shared a line with a brace, that brace would be commented out and the document would break.

Yes. Type, input, enum and interface definitions format the same way as operations, with fields indented inside their block.

They stay on one line with the field. Breaking arguments across lines is a style choice that different teams take differently, so this keeps them together and predictable.

Not currently. The tool exists to make an operation readable in a review or a ticket, which is the direction people usually need.

No. Formatting runs in your browser, which matters because queries often reveal internal schema and field names.

Yes, completely free with no sign-up.

Need a Custom Tool or Application?

We build production-grade web applications, SaaS platforms, and developer tools. Let's talk about your project.

or book a free call