Skip to content
toolgrid

No tool found. Try another word.

GraphQL Formatter

Format GraphQL queries, mutations, fragments and schemas: one field per line, arguments inline, consistent indentation. Or minify a query to one line.

Runs in your browser. What you enter is kept for 30 days to improve Toolgrid, then deleted.

How to use the GraphQL Formatter

  1. 1 Paste a GraphQL query or schema.
  2. 2 Choose Format or Minify, and the indentation.
  3. 3 Copy the result or download it as a .graphql file.

About the GraphQL Formatter

GraphQL queries copied from logs, network requests or code are often on one line, which hides the shape of the data you're asking for. The formatter puts every field of a selection set on its own line and indents nested selections, so the query reads like the JSON response it returns.

Arguments, variables, input objects and lists stay inline, with commas added between items (in GraphQL commas are optional and only for readability). Fragments and inline fragments (... on Type), directives such as @include and @skip, and schema definitions with descriptions are all handled. Definitions are separated by a blank line.

Minify does the opposite: it removes comments and all whitespace that isn't needed, producing the compact form that is sent in HTTP requests. The formatter is a small tokenizer written for this site; it doesn't check your query against a schema, so it formats syntactically valid GraphQL whether or not the fields exist.

Frequently asked questions

Does it validate my query?

It checks that the tokens are valid (strings closed, no unknown characters), not that fields and types exist in your schema. Use GraphiQL or your server for that.

Why were commas added?

Commas between arguments make them easier to read. GraphQL ignores commas, so they don't change the query.

Can I format a schema (SDL)?

Yes: type, input, enum, interface, union, scalar and directive definitions, including descriptions in quotes or triple quotes.

Are comments kept?

When formatting, yes; # comments are put on their own line. Minifying removes them.