GraphQL Formatter
Paste a GraphQL document and get it laid out cleanly.
INPUT
CHARS: 0WORDS: 0LINES: 0
OUTPUT
CHARS: 0WORDS: 0LINES: 0
How the GraphQL Formatter works
The formatter parses the document and prints it again with standard spacing: one field per line, arguments aligned, fragments and directives preserved and comments kept in place. Both executable documents (queries, mutations, subscriptions) and schema definitions (types, interfaces, enums) are supported.
Because it parses before printing, a syntax error such as an unclosed brace is reported with its location, which doubles as a quick validity check.
GraphQL Formatter examples
Format GraphQL query with clean nesting
Input
query GetUser{user(id:"123"){id name email profile{avatar bio}}}Result
query GetUser { user(id: "123") { id name email profile { avatar bio } } }
When it is useful
- •Making a query copied from a network inspector readable.
- •Standardizing schema files before committing them.
- •Checking a hand written query for missing braces.
- •Preparing queries for documentation or a pull request.
Frequently Asked Questions
Does it check my query against a schema?
No. It validates syntax only. It does not know your schema, so it cannot tell whether a field exists.
Are comments preserved?
Yes. Lines starting with a hash are kept where they are.
Can it format variables JSON as well?
Use the JSON Formatter for the variables object.
Related tools
- JSON Formatter and MinifierPaste JSON to validate it and print it neatly, or compress it to a single line.
- TypeScript FormatterPaste TypeScript and get it formatted with consistent style.
- JavaScript FormatterMake minified or messy JavaScript readable.
- YAML FormatterCheck your YAML parses, and print it with consistent indentation.