b2KIT

GraphQL Formatter & Validator

Format GraphQL queries, mutations, and schemas with syntax validation and pretty printing.

Tested tool guide Tested browser tools Checked August 16, 2026

What GraphQL Formatter & Validator does, with a checked example

GraphQL Formatter & Validator accepts GraphQL queries, mutations, fragments, and schema definition language, then rewrites valid source with consistent indentation and line breaks. It checks the text against GraphQL document grammar before presenting the formatted result, making unbalanced braces, incomplete selections, and malformed variable declarations easier to find. The common surprise is that syntactically valid GraphQL is not necessarily valid for a particular API. Unknown fields, incorrect argument types, and unavailable mutations require validation against that API's schema.

Worked example

A concrete input and expected output from the current implementation.

Input

query GetUser($id: ID!){user(id:$id){id
name}}

Expected output

query GetUser($id: ID!) {
  user(id: $id) {
    id
    name
  }
}

The operation, variable declaration, argument, and two selected fields are already valid GraphQL. Formatting adds consistent spaces, indentation, and line breaks without changing the requested selection set.

How the result is produced

1

GraphQL syntax checking

Validation first treats the paste as a GraphQL document. It checks whether operation definitions, variable definitions, selection sets, arguments, fragment syntax, and schema definitions follow GraphQL's grammar. Missing braces, malformed type notation, or an incomplete field selection prevent successful formatting. This is syntax checking; rules that depend on a particular service's schema are outside that result.

2

Structured pretty printing

Pretty printing rewrites the document's layout into a consistent, nested form. Selection sets are indented, braces and parentheses are separated consistently, and fields are placed on readable lines. Operation names, variables, arguments, directives, fragments, and SDL definitions remain GraphQL source. The returned text is suitable for copying into an editor, code review, documentation, or a GraphQL client.

Good uses

  • Expand a compressed query copied from a log or request payload so nested selection sets can be reviewed.
  • Check a newly edited mutation for missing braces, malformed variables, or broken argument syntax before sending it.
  • Normalize SDL containing type, input, interface, enum, union, scalar, or directive definitions for documentation and diffs.

Limits and checks

  • A successful syntax check does not confirm that fields, arguments, directives, fragment type conditions, or variable types exist in the target schema.
  • Formatting does not execute an operation, resolve fragments against runtime types, inspect returned data, or prove that authorization will permit the request.
  • Do not interpret textual changes as behavioral changes by themselves. GraphQL treats commas and most whitespace as insignificant separators, so equivalent documents can look different.

Common questions

Why can a formatted query still fail when I send it?

The formatter can establish that the document has valid GraphQL syntax, but the server applies additional checks. It may reject an unknown field, a missing required argument, an incompatible variable type, an invalid fragment placement, failed authentication, or application-specific rules. Use the target service's schema and actual server response to investigate those failures.

Does formatting send my query or mutation to a GraphQL endpoint?

No. This tool formats and checks the source entirely in the browser; it does not upload the document or execute it against an endpoint. Consequently, it cannot return query data, inspect server capabilities, test credentials, or confirm side effects from a mutation. The output is formatted GraphQL text, not an execution result.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools