MSRX Tools

GraphQL Formatter

Reindent or minify a query, mutation or schema.

Everything runs inside your browser. Your files never leave your device.

Input

Result

The result appears here as you type.

Ask about GraphQL Formatter

Questions about what this tool does, which option to pick, or what it can and cannot handle.

The question you type here is sent to an AI provider to be answered — your files and whatever you put in the tool above are not, and the assistant cannot see them. Answers are generated and can be wrong. The tool itself is not guessing: it runs deterministic code on your device.

About the GraphQL Formatter

GraphQL documents arrive unreadable more often than not. Copied from a network tab as one long line, pasted from a code file with the indentation of wherever it was embedded, or assembled by a client library that had no reason to be tidy. Reindenting by hand is a chore that has to be repeated every time.

This reformats queries, mutations, fragments and schema definitions, either indented for reading or minified onto a single line for sending. The indent width is yours to set, comments can be kept or dropped, and both directions work on the same document.

It formats by structure rather than by parsing into an abstract syntax tree, and that is a considered trade. A real parser would let the tool reorder fields and validate as it went, but it would also refuse anything with a syntax error — and a formatter is most wanted precisely when the document is a mess and you are trying to see what is wrong with it. This one reindents whatever it is given, so a query with an unbalanced brace still comes back readable enough to spot where the brace should have been.

Minifying is worth more here than for most formats. GraphQL queries travel in the request body on every call, and a large query pretty-printed carries a great deal of whitespace that is transmitted every single time. Stripping it is a straightforward saving on a hot path, and it is safe: whitespace outside string values carries no meaning in GraphQL.

String values, block strings delimited by triple quotes, and comments are all recognised and left alone, so a description containing braces will not confuse the indentation.

How to use it

  1. 1Paste the query, mutation, fragment or schema definition.
  2. 2Choose indented output for reading, or minified for sending over the wire.
  3. 3Set the indent width if two spaces is not your house style.
  4. 4Drop comments when minifying for production; keep them when the document is going back into source control.

Questions

Does it validate my query?
No, and deliberately. Validation needs a schema, and refusing to format a document with an error in it would remove the tool's usefulness at the exact moment you are hunting for that error. It reindents whatever you give it.
Is it safe to minify a query?
Yes. Outside string values, whitespace in GraphQL is purely separative. The minified document is exactly equivalent and is what a client library should be sending anyway.
Will it handle a full schema definition?
Yes — type definitions, interfaces, enums, inputs and directives all format the same way, since the tool works from the document's brace structure rather than from what the blocks mean.
What happens to descriptions in triple quotes?
They are recognised as block strings and passed through untouched, including any braces or hashes inside them, which would otherwise confuse the indentation.