Format GraphQL Queries Offline: Minify & Pretty Print
Format and minify GraphQL queries, mutations, and subscriptions instantly and offline on your desktop. Check syntax and beautify complex queries.
Get the tool mentioned in this guide in the desktop app:GraphQL Formatter
Why format GraphQL?
GraphQL queries can become deeply nested and hard to read, especially with multiple levels of fields, aliases, and variables. Formatting (pretty-printing) adds indentation and line breaks so relationships between fields are immediately visible.
Minifying removes all whitespace for production: smaller HTTP payload, faster transmission, less bandwidth used. Both formatting and minifying are useful at different stages: formatting during development, minifying before sending to production.
GraphQL query structure
A GraphQL query has three main parts: the operation type (query, mutation, subscription), optional variables, and the selection set of fields.
# Unformatted (hard to read)
query GetUser($id:ID!) { user(id:$id) { id name email posts { title createdAt } } }
# Formatted (easy to read)
query GetUser($id: ID!) {
user(id: $id) {
id
name
email
posts {
title
createdAt
}
}
}Minifying GraphQL for production
Minified queries have all whitespace removed and variable names shortened (if you control the server). Minification saves 20-40% on HTTP payload size for large queries.
# Minified query
query GetUser($id:ID!){user(id:$id){id name email posts{title createdAt}}}
# Original minified size: ~70 chars
# Original formatted size: ~150 chars
# Savings: ~53%Common GraphQL formatting issues
Unbalanced braces or parentheses — Check that every opening { has a matching } and every field argument is enclosed in parentheses.
Undefined variables — If a query uses $variableName, it must be declared in the query signature.
Invalid field names — Queries can only request fields that exist in the schema. Use a formatter to catch typos.
Frequently asked questions
Should I send formatted or minified queries to my GraphQL server?
The server does not care about formatting. Minified is smaller over the wire; formatted is easier to debug. Choose based on your needs.
Can I format a GraphQL mutation or subscription the same way as a query?
Yes, all GraphQL operations (query, mutation, subscription) use the same formatting rules.
Does formatting validate my GraphQL?
A formatter checks for basic syntax (balanced braces, valid structure). It does not validate against a schema — only your GraphQL server does that.

