Moayyad Faris
JSON and Data

Processed locally in your browser — not uploaded

GraphQL Query Formatter & Minifier

Format raw GraphQL queries, mutations, subscriptions, and SDL schema definitions into clean, indented code or minify them into compact single-line payload strings for HTTP requests. Parsed with graphql-js, the reference implementation, so string literals are preserved and syntax errors are reported with their line and column. Runs entirely in your browser.

query GetUserOrders($userId: ID!, $limit: Int) {
  user(id: $userId) {
    id
    name
    email
    orders(first: $limit) {
      edges {
        node {
          id
          totalAmount
          status
          createdAt
        }
      }
    }
  }
}
01

How to use

  1. Paste a GraphQL query, mutation, subscription, fragment, or SDL schema — minified one-liners work too.
  2. Click 'Format Indented GraphQL' for readable, consistently indented output.
  3. Click 'Minify Single Line' to strip whitespace, commas, and comments for a compact request payload.
  4. Copy the result or download it as a .graphql file.
02

Understanding the output

Input is parsed with graphql-js, the GraphQL reference implementation, then printed back out. Formatting puts one field per line with two-space indentation; minifying removes only the characters the GraphQL spec defines as ignored, so the server executes exactly the same document. Invalid input shows the parser's error with its line and column instead of output.

03

Common issues & tips

  • •"Expected Name, found <EOF>" means the document ended early — almost always a missing closing brace. The reported line and column show where the parser stopped.
  • •Comments (# …) are ignored tokens in GraphQL, so both formatting and minifying drop them. Keep your commented source in version control.
  • •A query that formats cleanly can still fail on the server: this tool checks syntax, not whether fields exist in your schema.
  • •Variables are not part of the query string. Send them separately in the request's variables object rather than inlining values.

What formatting and minifying actually change

Both modes parse your input into a syntax tree first, so they never guess at structure from line breaks. That is why a minified single-line query formats correctly, and why a string argument like "color #fff" survives untouched — a regex-based formatter would treat #fff as a comment.

Formatting prints the tree back with one selection per line, two-space indentation, and consistent name: value spacing:

GraphQL
query GetUser($id: ID!) {  user(id: $id) {    name    avatar(size: 64)  }}

Minifying removes what the GraphQL specification calls *ignored tokens* — whitespace, line terminators, commas, and comments — and nothing else:

GraphQL
query GetUser($id:ID!){user(id:$id){name avatar(size:64)}}
CharactersFormattedMinified
Whitespace and line breaksNormalizedRemoved where not needed to separate tokens
CommasKept between arguments, dropped between fieldsRemoved (they are optional in GraphQL)
# commentsRemovedRemoved
String and block-string contentsPreserved exactlyPreserved exactly

Sending a minified query over HTTP

Most GraphQL servers accept a JSON POST body with query, optional variables, and optional operationName. Paste the minified output straight into the query field:

JSON
{  "query": "query GetUser($id:ID!){user(id:$id){name avatar(size:64)}}",  "variables": { "id": "42" }}

Minifying matters most for GET requests, where the query travels in the URL's query parameter and every byte counts against URL length limits. For POST bodies served with gzip or Brotli, the saving is usually small — readability in your codebase matters more. See Serving over HTTP for the request formats servers commonly support.

Frequently asked questions

Are my GraphQL queries sent to an external server?
No. Formatting and minification happen 100% locally inside your web browser.
Does minifying a GraphQL query change what the server executes?
No. Minifying removes only ignored tokens defined by the GraphQL specification — whitespace, line terminators, commas, and comments. String literal contents are preserved exactly, so the server parses the same document.
Why did my # comments disappear?
Comments are ignored tokens in GraphQL. The formatter parses your input and prints it back from the syntax tree, which does not retain comments. Keep commented source in version control and format or minify a copy.
Can it format GraphQL schema (SDL) files?
Yes. Type, interface, enum, input, union, scalar, directive, and schema definitions are parsed by the same parser and printed with consistent indentation.
What does "Expected Name, found <EOF>" mean?
The document ended before the parser expected it to — usually a missing closing brace. The line and column in the message show where parsing stopped.

Related tools

Related guides