GraphQL Query Formatter

Format or minify GraphQL queries, mutations and fragments, and check them: brackets, unused or undeclared variables, missing fragments and query depth.

Tool

Was this tool useful?

About this tool

About GraphQL Query Formatter

Paste a messy one-line GraphQL query and get it neatly indented, or minify it for sending. The formatter handles operations, variables with defaults, arguments, input objects, lists, aliases, fragments, inline fragments, directives and block strings, and it checks the query: unbalanced brackets, variables declared but not used (or used but not declared), fragments that are missing or never used, and very deep queries that servers may reject.

How it works

The query is split into GraphQL tokens (names, numbers, strings, block strings, punctuators, comments; commas are ignored as the spec says) and printed again with indentation per selection set.

Example

query GetOrders($first:Int=10,$status:OrderStatus!){orders(first:$first){totalCount}} becomes a readable 5-level query; depth 5, one operation, no warnings.

How to use this tool

  1. Paste your query.
  2. Choose pretty (2 or 4 spaces) or minified.
  3. Read the warnings and copy or download the result.

Frequently asked questions

Does it check my schema?

No – it checks the query syntax and its own variables and fragments. Field names are checked by your GraphQL server.

Is my query sent anywhere?

No, it is formatted in your browser.

Is my data uploaded?

No. Everything runs in your browser and stays on this device.

Does the GraphQL Query Formatter send my data to a server?

No. The GraphQL Query Formatter runs entirely in your browser using JavaScript, so tokens, code and data you paste stay on your device. You can even use it offline once the page has loaded.