GraphQL Formatter & Minifier

Pretty-print or minify GraphQL queries and SDL schemas, with the exact line and column of any syntax error.

More options

Paste a query, mutation, fragment or SDL schema above, or .

No uploads. Your files stay on your device.

Free forever, no sign-up, no cookies. Buy me a coffee

How it works

Paste a GraphQL operation or SDL schema and it is re-printed instantly. The page contains a hand-written tokenizer that follows section 2 (Language) of the GraphQL specification, October 2021 edition: punctuators, names, integer and float values, strings and block strings, and the ignored tokens (whitespace, line terminators, commas, BOM and # comments). The formatter then re-emits those tokens with one selection or field per line, arguments kept inline and separated by commas, and 2-space, 4-space or tab indentation. Minify mode collapses the document to a single line, dropping every comma, comment and non-essential space while keeping the space between two adjacent names so the result still tokenizes the same way.

Errors are reported with a line and column: an unterminated string, an invalid escape, a malformed number such as 01 or 1., an unexpected character, or an unbalanced {, ( or [. This is a lexer plus a bracket-balance check, not a full grammar validator, so it will not tell you that a field does not exist on a type or that an argument has the wrong kind of value โ€” use your schema or a linter for that.

Everything runs in your browser. Nothing is uploaded, so it is safe for internal schemas and queries that contain customer identifiers. Use Copy result or Download .graphql to take the output with you.

Frequently asked questions

How do I format a GraphQL query online?

Paste the query, mutation, fragment or SDL schema into the box and it is re-printed as you type: one selection or field per line, arguments kept inline, and 2-space, 4-space or tab indentation. Switch the output to Minify to collapse it to a single line instead, then use Copy result or Download .graphql.

What does this tool actually check?

It contains a hand-written tokenizer that follows section 2 (Language) of the GraphQL specification, October 2021 edition, plus a bracket-balance check. So it catches unterminated strings, invalid escapes, malformed numbers such as 01 or 1., unexpected characters and unbalanced braces, parentheses or square brackets, and reports each with a line and column. It is not a schema-aware validator: it will not tell you that a field does not exist on a type.

Is my query or schema uploaded anywhere?

No. The tokenizer, the formatter and the minifier all run in your browser, so nothing leaves your device. That makes it safe for internal schemas and for queries that contain customer identifiers, unlike formatter sites that POST your document to their own backend.

Report a bug