GraphQL Formatter
Format and indent GraphQL queries, mutations, and schemas.
Last updated: August 2026
Indents GraphQL queries, mutations, and schemas by brace nesting.
Was this tool helpful?
Consistent GraphQL layout
A GraphQL formatter re-indents queries, mutations, and schema definitions to a consistent style: nested selection sets indented, arguments spaced predictably, braces aligned. The operation is not changed, only its layout, which makes a hand-written or machine-glued query readable and diff-friendly.
Example
Messy input:
query{user(id:7){name posts{title}}}Formatted:
query {
user(id: 7) {
name
posts {
title
}
}
}The nested posts selection set is indented under user, and the argument id: 7 gets a space after the colon, matching the convention most GraphQL tooling expects.
Formatting is not validation
A formatter checks that the query is syntactically parseable, but it does not know your schema. It cannot tell you that posts is not a field on User or that an argument type is wrong. Those are schema-validation errors a server or a schema-aware linter catches, not something indentation can reveal. Treat a clean format as "the syntax is sound," nothing more.
Fragments and schema SDL
The same tool typically formats fragment definitions and schema SDL (thetype, input, and enum blocks). Watch directives and multi-line descriptions, which some formatters reflow and others leave as-is; if a formatter mangles a triple-quoted description, that is usually the cause.
FAQ
Will it reorder my fields? No. Field order is significant in a GraphQL response, so a formatter preserves it and only adjusts whitespace.
Does it strip comments? GraphQL comments start with #. Good formatters keep them, but some drop them because they are not part of the parsed AST, so check before relying on it.