GraphQL Formatter

Paste a GraphQL query, mutation or schema and get it properly indented, or minified down to a single line. Syntax is checked as you type, with the line and column of the first problem and a specific reason. Two things it gets right that matter: commas are dropped, because GraphQL treats them as whitespace rather than separators and idiomatic GraphQL does not use them — keeping them produces output nobody would have written by hand. And block string descriptions, the triple-quoted ones in a schema, are emitted exactly as written, because they routinely contain braces and line breaks that a reflowing formatter would destroy along with the documentation. Arguments stay on one line rather than sprawling, and declarations like `query GetUser($id: ID!)` are kept intact. It also shows the field count and nesting depth, which is a quick way to spot a query that is deeper than you meant.

GraphQL details this respects

DetailBehaviour
CommasWhitespace per spec — dropped
"""descriptions"""Emitted verbatim
Braces inside stringsNot counted as structure
query Name($v: T!)Kept on one line
fragment F on TypeKept on one line
field(a: 1 b: 2)Arguments stay inline
Schema validationNot done — needs your schema

When to use it

  1. Make a one-line query from a network log readable.
  2. Tidy a schema file before committing it.
  3. Find the unbalanced brace in a query that will not run.
  4. Minify a query to embed in a URL or a test.
  5. Check how deeply a query nests before sending it.

How to Use

  1. Paste a query, mutation or schema.
  2. Choose an indent width, or switch to minify.
  3. Fix anything reported at the line and column given, then copy.

Features

  1. Format queries, mutations and schemas
  2. Minify to a single line
  3. Syntax errors with exact line and column
  4. Commas handled per the specification
  5. Block string descriptions preserved verbatim
  6. Brackets inside strings correctly ignored
  7. Arguments kept on one line
  8. Field count and nesting depth
  9. 100% client-side

FAQs

Is my query uploaded?

No. It is tokenised and reprinted in your browser. Queries often embed IDs and tokens, so nothing is transmitted.

Why were my commas removed?

Because GraphQL defines commas as insignificant whitespace, not separators. They are legal but idiomatic GraphQL omits them, so the output matches what you would see in real schemas and documentation.

Does it validate against my schema?

No. It checks syntax — that the brackets balance and the document is structurally sound. Whether a field exists or an argument has the right type requires the schema itself, which is a different and much larger job.

Will it reformat my descriptions?

No. Triple-quoted block strings are emitted exactly as written. Their line breaks and indentation are part of the documentation, and reflowing them would damage it.

Why are arguments kept on one line?

Because that is the convention, and because breaking them makes a field with three arguments sprawl over five lines for no benefit. Nesting comes from selection sets, which is what the indentation shows.

What does the depth number mean?

How many selection sets deep the query nests. It is worth watching — many servers impose a depth limit to prevent expensive queries, and a deeply nested query is often accidental.

Technical Details

The document is tokenised and reprinted, rather than parsed into an abstract syntax tree by the reference implementation — which is several hundred kilobytes to ship for what is, at this level, a tokenizer and a printer. Two details of the GraphQL grammar drive the design. Commas are insignificant: the specification defines them as whitespace, not separators, so they are discarded rather than preserved, because keeping them would produce output that does not look like the GraphQL anyone writes. And block strings delimited by triple quotes are captured whole and emitted verbatim, because they are how descriptions are written in a schema and routinely contain braces, quotes and line breaks that would otherwise be read as structure — a formatter that reflows them corrupts the documentation it was asked to tidy. Printing indents on braces only; arguments inside parentheses stay on one line, which is how GraphQL is conventionally written and keeps a field with three arguments from sprawling over five lines. Declarations outside any selection set are kept on a single line, so `query GetUser($id: ID!)`, `fragment Fields on User` and `type Thing implements Node` each stay intact rather than breaking after the keyword. Syntax checking reports the first bracket problem with a line and column — unclosed, unopened, or a mismatched pair — and correctly ignores brackets that appear inside strings and block strings. It is a syntax check, not schema validation: it can tell you the braces do not balance, not whether the field you asked for exists, which requires the schema itself. Everything runs in your browser.

Developer Tools

Developer Tools

  • Prettier Playground
  • XML Formatter
  • cURL Command Builder
  • cURL to Code
  • HTTP Status Codes
  • Subnet Calculator
  • IP & MAC Validator
  • URL Parser