GraphQL Formatter
Format or minify GraphQL queries and schemas, with the error location named.
Re-Printed, Not Re-Indented
A GraphQL query that arrives from a network tab or a log is usually one long line. Adding newlines by hand is tedious and error-prone, and most "formatters" work by inserting whitespace around brackets — which breaks the moment a string in the query contains one.
This tokenises the document and prints it again from the tokens. Strings, block strings and comments are carried through untouched, commas are dropped because GraphQL treats them as whitespace, and the output is a faithful rendering of what the server will actually parse.
Key features
- Tokenises rather than patches whitespace — a brace inside a string cannot confuse it.
- Names where the error is — unbalanced brackets and unterminated strings are reported by line.
- Handles block strings — triple-quoted descriptions pass through as written.
- Minifies as well — the same tokens printed with nothing optional, for embedding in code.
- Works on schemas too — type definitions, interfaces and unions, not just queries.
This tool runs entirely inside your browser using native Web APIs. Your files and text are never uploaded to a server, never logged and never shared with third parties.
How to use: GraphQL Formatter
- Paste a query or schema
Or load the example, which is deliberately unformatted. - Choose an indent
Two spaces is the community convention; four and tab are there if your project differs. - Read the result
If the brackets do not balance, the line number is named instead. - Copy, or minify instead
Minified output is useful when a query has to live inside a string in source code.
Technical specifications
| Processing location | Entirely in your browser — no server round trip |
|---|---|
| Data uploaded | None. Files and text never leave your device |
| Price | Free — no account, no trial, no usage cap |
| Category | Developer |
| Works offline | Yes, once the page has loaded |
| Browser support | Chrome 90+, Edge 90+, Firefox 90+, Safari 15+ |
| Interface languages | English, 中文, हिन्दी, Español, العربية |
Frequently asked questions
Does this validate my query against a schema?
No. It checks that the document is syntactically well formed — that it tokenises and the brackets balance. Whether the fields exist, the arguments are the right type or the query is allowed requires the schema, which only your server has. This catches the class of mistake you can find without one.
Why did my commas disappear?
GraphQL treats commas as insignificant whitespace, exactly like spaces and newlines. They are dropped when the document is tokenised and re-inserted only inside argument lists, where they aid reading. The result is identical to the server.
Is the minified version safe to use?
Yes — it is the same tokens with only optional whitespace removed, so the server parses it identically. It is genuinely useful for embedding a query in a source file, though a persisted-query setup is usually a better answer for size.
What is the difference between a query and a mutation here?
For formatting, nothing — both are operations with a selection set and both are printed the same way. The distinction matters to the server, which will only execute a mutation where one is permitted, not to the shape of the text.