GraphQL Formatter
Part of Code formatters
GraphQL formatter: indent queries, mutations, and fragments
A GraphQL formatter indents field selections, variables, and nested fragments so you can review API calls in PRs, GraphQL Playground exports, and support tickets. Readable queries make missing fields and alias mistakes obvious.
The formatter does not execute queries against a server or validate against a live schema—it only improves layout.
How to use this converter
- Paste a query, mutation, subscription, or fragment definition.
- Format to align braces and field lists.
- Copy into your client, documentation, or test file.
- Run the operation against your API to confirm variables and types.
Before and after examples
| Original | Converted | Notes |
|---|---|---|
| query{user(id:"1"){name email}} | Indented query with field list | Simple query |
| mutation CreateItem($input:ItemInput!){createItem(input:$input){id}} | Variables + mutation body | Mutation with variable |
Queries, variables, and aliases
Formatted output groups arguments under field names and lines up `$variable` declarations at the top of operations. Aliases (`user: accountOwner`) stay intact—formatting only changes whitespace.
Large inline fragments (`... on Product`) nest visually so you can audit union selections before shipping mobile clients.
Code review and documentation
Teams paste minified queries from network tabs into this tool before attaching them to tickets. Technical writers clean examples for README files without manually spacing every brace.
Pair with the JSON formatter when inspecting GraphQL HTTP responses—request body here, response body there.
Schema awareness and tooling
Invalid GraphQL syntax still fails parsing. Schema validation (required arguments, enum values) belongs in your IDE extension or CI pipeline, not in a layout formatter.
Frequently asked questions
Does GraphQL Formatter run queries against my API?
No. It only formats text locally. Execute operations in your GraphQL client or server tools.
Can I format subscriptions and fragments?
Yes. Paste full operations including `fragment` definitions and inline spreads.
Will formatting change field names?
No. Only whitespace changes; selections and arguments stay identical.