Part of Code & data tools
GraphQL formatter: indent queries, mutations, and fragments
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.
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.
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 |