Minify GraphQL

Minify GraphQL documents by removing insignificant comments and whitespace.

freeworks offlinenothing uploaded
ToolGraphQL Minifier
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Comments and optional whitespace are removed between tokens while names, punctuation, string values, and block strings remain unchanged. Compact serialization preserves selection and argument structure.

  • GraphQL ignores whitespace outside values.
  • Smaller requests suit persisted queries and mobile clients.

Worked example

Minify a GraphQL query
Remove whitespace from a formatted GraphQL query
Input
											query {
  user(id: 1) {
    name
    email
  }
}
										
Output
												query{user(id:1){name email}}
											

When to use this

Persisted query storage, mobile requests, and normalized cache keys minify GraphQL.

Edge cases

  • Whitespace inside a quoted string is data.
  • Block strings retain newline and indentation meaning.
  • A # inside a string is not a comment marker.

References