Tokenizer-based GraphQL beautify and minify for queries and SDL schemas.
⚡ A real tokenizer — not regex line hacks: strings, block strings, # comments, directives, variables and fragments round-trip safely. Comments are kept when beautifying and dropped when minifying; commas are insignificant in GraphQL and normalized away.
JSON formatters cannot help here: GraphQL is a language with arguments, directives, variables, fragment spreads and multi-line block strings, and a formatter that only matches braces will chew those up. This tool runs a real tokenizer over the document, so strings containing braces, hashes and commas round-trip untouched — and the pretty printer rebuilds indentation from the token stream rather than from whatever whitespace your source happened to have.
A quirk that surprises newcomers: commas in GraphQL are insignificant tokens, pure readability sugar. The formatter normalizes them back in where humans expect them (between arguments, between variable definitions) while the minifier can drop every one safely. What it never drops is the whitespace that separates two adjacent name tokens — "query Q" needs the space; "a{b}" does not.
Pasting an incomplete query mid-edit is the normal case, not the exception. Unclosed braces, unterminated strings and stray characters are reported with their position instead of producing confident-looking garbage — the formatter refuses to output when the input does not balance, so what you copy out is always either correct or explicitly rejected.
Schema files (type, interface, union, enum, input, triple-quoted descriptions) tokenize with the same rules as operations, so .graphql schema files format here too. Minifying operations still pays off where queries travel: embedded strings in apps, persisted-query registration, and request logs — a 40% trim on a long query with comments is typical.
More tools you might find useful
Generate SHA-256 and SHA-1 hashes from text.
301s, domain moves, HTTPS and canonical rules without tears.
Escape HTML special characters to prevent XSS attacks.
Convert HTML entities back to readable characters.