GraphQL formatter
Pretty-print, minify, validate, sort, and comment-strip GraphQL documents locally.
About this tool
Paste a GraphQL query, mutation, subscription, fragment, or SDL schema and get a validated, consistently formatted document back. The formatter parses the GraphQL grammar before printing, so syntax errors include a line and column instead of silently rearranging invalid text.
Use the indent selector for two spaces, four spaces, eight spaces, or tabs. Choose minify when you need a compact payload for examples or tests, enable sort fields for stable diffs, and enable remove comments when you want formatted output without # notes.
Worked example:
Input:
query Hero($episode: Episode = JEDI) { hero(episode: $episode) { name friends { name } } }
Output with the default settings:
query Hero($episode: Episode = JEDI) {
hero(episode: $episode) {
name
friends {
name
}
}
}
Limits and edge cases: input is capped at about 500 KB, nesting is capped at 64 levels, minify mode always removes comments, and the parser focuses on standard GraphQL executable documents and SDL definitions rather than vendor-specific non-GraphQL template wrappers.
FAQ
Does this validate the GraphQL syntax?
Yes. The tool lexes and parses the document before printing it. If the source is not valid GraphQL, the output shows a syntax error with a line and column so you can jump to the problem.
Can it format schema definition language as well as queries?
Yes. It handles operations, fragments, schema definitions, object and input types, enums, unions, scalars, directives, descriptions, and common SDL extensions.
What does sort fields change?
It sorts selection fields recursively and sorts object/input fields in SDL blocks. That is useful for stable generated diffs, but leave it off when field order is meaningful for human review.
Does minify preserve comments?
No. GraphQL comments are ignored tokens, so minify mode drops them. If you want readable output with comments removed, use format mode with Remove comments enabled.
Developer & Automation Access
Run it from the terminal
Same engine as this page, headless — via the gizza CLI:
gizza tool graphql-formatter 'query Hero($episode: Episode = JEDI) { hero(episode: $episode) { name friends { name } } }'New to the CLI? Get gizza →
Open it by URL
Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:
https://gizza.ai/tools/graphql-formatter/?input=query%20Hero%28%24episode%3A%20Episode%20%3D%20JEDI%29%20%7B%20hero%28episode%3A%20%24episode%29%20%7B%20name%20friends%20%7B%20name%20%7D%20%7D%20%7D&indent=2&mode=format&sort_fields=true&remove_comments=trueMachine-readable descriptor: tool.json — title + parameters JSON Schema for agents.
