ZeroTool Workbench

GraphQL Formatter

Free online GraphQL formatter. Beautify, minify, and validate queries, mutations, and SDL schemas in your browser. Syntax errors with line and column. No upload.

100% Client-Side Your data never leaves your browser Free · No Sign-Up

How to Use

  1. Paste your GraphQL query, mutation, subscription, or SDL schema into the input area, or click Load sample to start from an example.
  2. Click Format to beautify, Minify to compress, or Validate to check syntax only.
  3. Switch indent between 2 and 4 spaces — the default 2 matches graphql-js native output.
  4. Click Copy or Download .graphql to take the result with you. Press Cmd/Ctrl + Enter to format from the keyboard.

Worked Examples

Before formatting

query GetUser($id:ID!,$withPosts:Boolean!){user(id:$id){id name email posts @include(if:$withPosts){...PostSummary}}} fragment PostSummary on Post{id title publishedAt}

After formatting

query GetUser($id: ID!, $withPosts: Boolean!) {
  user(id: $id) {
    id
    name
    email
    posts @include(if: $withPosts) {
      ...PostSummary
    }
  }
}

fragment PostSummary on Post {
  id
  title
  publishedAt
}

SDL schema

type Post {
  id: ID!
  title: String!
  publishedAt: DateTime
  author: User!
}

type Query {
  post(id: ID!): Post
  posts(authorId: ID, limit: Int = 20): [Post!]!
}

Why Format GraphQL?

Consistent GraphQL formatting matters for code review, schema diffs, and storing operations in .graphql files. Minified queries shrink wire payloads when you cannot rely on persisted queries; pretty-printed queries are easier to scan in PRs. Validating a query in isolation — before piping it to an endpoint — surfaces a typo in a fragment name in seconds rather than after a round-trip.

Behind the Scenes

This tool runs graphql-js (the reference implementation maintained by The GraphQL Foundation) entirely inside your browser. parse() builds an AST from your text and reports the first syntax error with line and column. print() serializes the AST back to canonical GraphQL. stripIgnoredCharacters() removes every token the spec marks as ignored — that is the minified form. Nothing is sent anywhere, and there is no server round-trip.

FAQ

What GraphQL constructs are supported?

Queries, mutations, subscriptions, fragments, inline fragments, variables, directives (@include, @skip, @deprecated, custom), and SDL type system definitions (type, interface, union, enum, input, scalar, extend, schema). The parser uses the official `graphql` reference implementation, so anything graphql-js accepts works here.

Is my schema or query sent to a server?

No. Parsing, printing, and validation all run inside your browser tab. Nothing leaves your device. ZeroTool has no upload endpoint for this tool by design.

Does it type-check against a remote schema?

Syntax-level validation only. The tool checks that your text is valid GraphQL grammar, not that fields exist on a particular schema. For type-aware validation run `graphql-cli`, `apollo client:check`, or `graphql-inspector` against your endpoint locally.

What is the maximum supported input size?

10 MB hard cap. GraphQL operations are rarely that large; if yours is, you are likely staring at a generated schema introspection dump — pipe it through `prettier --parser graphql` locally instead.

How does Minify differ from Format?

Minify uses graphql-js `stripIgnoredCharacters`, removing every whitespace and comment that the GraphQL spec calls ignored — safe to wire-transfer. Format reprints the AST with 2 or 4 space indent for human reading.