Developer · Formatter
GraphQL formatter.
Paste a GraphQL query, mutation, fragment or schema (SDL) to pretty-print it or squeeze it onto one line. Syntax errors come back with a line and column. Runs in your browser; nothing is sent anywhere.
Input
Result
Paste GraphQL and press Run.
How the GraphQL formatter works
Formatting uses Prettier 3.9.9 (standalone build plus its GraphQL plugin, MIT licence), which parses the text with graphql-js and prints it in Prettier's GraphQL style: one field per line, a space after each colon, commas removed, and consistent indentation. It works on executable documents (queries, mutations, subscriptions, fragments) and on schema definitions (SDL) alike.
Minifying removes what the GraphQL specification calls ignored tokens: whitespace, line breaks, comments and commas (September 2025 edition, Language › Source Text). A single space is kept only between two names or numbers that would otherwise run together, and string values, including block strings, are left exactly as written. Because commas are ignored tokens, a(x: 1, y: 2) becomes a(x:1 y:2), which means the same thing.
Worked example. The query query Q($id:ID!){user(id:$id){name,...F}} formats to four short lines, with $id: ID! spaced and ...F on its own line. The loaded example (the query plus fragment F on User) is 70 characters as typed and 97 once formatted; minified it is 68 characters on one line: query Q($id:ID!){user(id:$id){name...F}}fragment F on User{id email}. The size shown after minifying is a character count, before and after.
Errors: if the text is not valid GraphQL syntax you get the parser's message and the line and column where it stopped, both counted from 1. Nothing is output until the syntax is fixed.
Sources: GraphQL specification, September 2025 (spec.graphql.org); Prettier, browser / standalone usage (prettier.io), vendored at version 3.9.9. Sources checked 2026-09-30.
Frequently asked questions
Does it check my query against my schema?
No. It checks syntax only. An unknown field or a wrong argument type still formats fine, because that needs your schema to detect.
Does minifying change what the query does?
No. Whitespace, commas and comments are ignored tokens in GraphQL, so the minified text parses to the same document. Strings are not touched.
Where did my comments go when I minified?
Minifying drops # comments, since they are ignored tokens. Formatting keeps them.
Is my query uploaded anywhere?
No. Prettier runs in your browser and nothing you paste is stored or sent.
Syntax check only
This tool confirms the text is syntactically valid GraphQL and re-prints it. It does not validate against a schema, run the query, or check variables.