Skip to content

GraphQL Formatter

Formats queries and SDL, validates a document against a schema and prints the type it resolves to.

Reprints a GraphQL document in the conventional style — one field per line, arguments spaced, indentation by selection depth. It parses the full October 2021 grammar, so a schema file with directives, interfaces and unions goes through as readily as a query.

🔒 Runs entirely in your browsergraphqlformatschema

GraphQL in

Formatted

Token stream

identical to the input

Parses the complete October 2021 grammar — operations, fragments and the full type-system language — and reprints it in the conventional style. Comments are kept, commas are normalised away (they are ignored tokens), and the output is verified on every run to carry exactly the input’s tokens.

How to use it

  1. Paste the document or open a file

    A query, a mutation, a fragment, or a whole `.graphql` schema. Anonymous and named operations are both fine.

  2. Check the token stream line

    After every run the formatter re-tokenises its own output and compares it to the input. The stat says "identical to the input" when nothing but layout moved — and shouts if it did not.

  3. Copy or download the result

    The download is a `.graphql` file with the right MIME type, ready to drop into a schema directory.

Common questions

Where did my commas go?

GraphQL treats commas as ignored tokens — they are whitespace with a shape. The formatter normalises them away because the conventional style has none, and no meaning is lost by removing them.

Are comments kept?

Yes, and the comparison after each run checks that too — the comment tokens in the output have to match the ones that went in. A formatter that drops the `# deprecated` line above a field has broken the document as far as the next reader is concerned.

Does it validate the query against a schema?

No. It checks the grammar, not the meaning — a query asking for a field that does not exist is syntactically perfect and formats fine. Validation needs the schema, which this page never has.

Feed it from

Next

These accept what this tool produces, so the result can go straight in.